当前位置: 首页>>代码示例>>Java>>正文


Java PhoneLookup类代码示例

本文整理汇总了Java中android.provider.ContactsContract.PhoneLookup的典型用法代码示例。如果您正苦于以下问题:Java PhoneLookup类的具体用法?Java PhoneLookup怎么用?Java PhoneLookup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PhoneLookup类属于android.provider.ContactsContract包,在下文中一共展示了PhoneLookup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContactsWithPush

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("XecureChat", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:ContactAccessor.java

示例2: isSystemContact

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public boolean isSystemContact(Context context, String number) {
  Uri      uri        = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  String[] projection = new String[]{PhoneLookup.DISPLAY_NAME, PhoneLookup.LOOKUP_KEY,
                                     PhoneLookup._ID, PhoneLookup.NUMBER};
  Cursor   cursor     = context.getContentResolver().query(uri, projection, null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      return true;
    }
  } finally {
    if (cursor != null) cursor.close();
  }

  return false;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:ContactAccessor.java

示例3: getContactUriForNumber

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:ContactIdentityManagerGingerbread.java

示例4: getSelfIdentityUri

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:26,代码来源:ContactIdentityManagerICS.java

示例5: onClick

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:24,代码来源:ContactBadge.java

示例6: getContactsWithPush

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:24,代码来源:ContactAccessor.java

示例7: getContactsWithPush

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<ContactData>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:24,代码来源:ContactAccessor.java

示例8: getRecipientDetails

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri contactUri      = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      Bitmap contactPhoto = ContactPhotoFactory.getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI,
                                                                                              cursor.getLong(2)+""));
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto,
                                  BitmapUtil.getCircleCroppedBitmap(contactPhoto));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:21,代码来源:RecipientProvider.java

示例9: getRecipientDetails

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri      contactUri   = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      String   name         = cursor.getString(3).equals(cursor.getString(0)) ? null : cursor.getString(0);
      Drawable contactPhoto = ContactPhotoFactory.getContactPhoto(context,
                                                                  Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""),
                                                                  name);
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return new RecipientDetails(null, number, null, ContactPhotoFactory.getDefaultContactPhoto(context, null));
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:22,代码来源:RecipientProvider.java

示例10: getContactId

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public static String getContactId(String phoneNumber, Context context) {
	ContentResolver mResolver = context.getContentResolver();

	Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
			Uri.encode(phoneNumber));

	Cursor cursor = mResolver.query(uri, new String[] {
			PhoneLookup.DISPLAY_NAME, PhoneLookup._ID }, null, null, null);

	String contactId = "";

	if (cursor.moveToFirst()) {
		do {
			contactId = cursor.getString(cursor
					.getColumnIndex(PhoneLookup._ID));
		} while (cursor.moveToNext());
	}

	cursor.close();
	cursor = null;
	return contactId;
}
 
开发者ID:MaxIndu,项目名称:Wi-SMS,代码行数:23,代码来源:ContactsRetriever.java

示例11: getContactName

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public static String getContactName(String phoneNumber, Context context) {
	ContentResolver mResolver = context.getContentResolver();

	Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
			Uri.encode(phoneNumber));

	Cursor cursor = mResolver.query(uri, new String[] {
			PhoneLookup.DISPLAY_NAME, PhoneLookup._ID }, null, null, null);

	String contactId = "";

	if (cursor.moveToFirst()) {
		do {
			contactId = cursor.getString(cursor
					.getColumnIndex(PhoneLookup.DISPLAY_NAME));
		} while (cursor.moveToNext());
	}

	cursor.close();
	cursor = null;
	return contactId;
}
 
开发者ID:MaxIndu,项目名称:Wi-SMS,代码行数:23,代码来源:ContactsRetriever.java

示例12: getContactName

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public static String getContactName(Context context, String phoneNumber) {
	ContentResolver cr = context.getContentResolver();
	Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
	Cursor cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
	if (cursor == null) {
		return null;
	}
	String contactName = null;
	if (cursor.moveToFirst()) {
		contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
	}

	if (cursor != null && !cursor.isClosed()) {
		cursor.close();
	}

	return contactName;
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:19,代码来源:SmsReceiver.java

示例13: getContactName

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public static String getContactName(Context context, String phoneNumber) {
	if (phoneNumber == null || phoneNumber.length() == 0)
		return phoneNumber;
	ContentResolver cr = context.getContentResolver();
	Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
	Cursor cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
	if (cursor == null) {
		return null;
	}
	String contactName = null;
	if (cursor.moveToFirst()) {
		contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
	}

	if (cursor != null && !cursor.isClosed()) {
		cursor.close();
	}

	return contactName;
}
 
开发者ID:manuelsc,项目名称:Raven-Messenger,代码行数:21,代码来源:MainActivity.java

示例14: getContactName

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public String getContactName(String phoneNumber) {
    ContentResolver cr = this.getContentResolver();
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    Cursor cursor = cr.query(uri, new String[] {PhoneLookup.DISPLAY_NAME}, null, null, null);
    if(cursor == null) {
        return null;
    }
    String contactName = null;
    if(cursor.moveToFirst()) {
        contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }
    if(cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return contactName;
}
 
开发者ID:jareddlc,项目名称:OpenFit,代码行数:17,代码来源:OpenFitService.java

示例15: getContactName

import android.provider.ContactsContract.PhoneLookup; //导入依赖的package包/类
public static String getContactName(Context ctx, String phoneNumber) {
	final ContentResolver cr = ctx.getContentResolver();
	final Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
			Uri.encode(phoneNumber));
	Cursor cursor = null;
	String contactName = phoneNumber;
	try {
		cursor = cr.query(uri, new String[] { PhoneLookup.DISPLAY_NAME },
				null, null, null);
		if (cursor == null) {
			return null;
		}

		if (cursor.moveToFirst()) {
			contactName = cursor.getString(cursor
					.getColumnIndex(PhoneLookup.DISPLAY_NAME));
		}
	} finally {
		if (cursor != null && !cursor.isClosed()) {
			cursor.close();
		}
	}
	return contactName;
}
 
开发者ID:arthurzaczek,项目名称:launcherforblind,代码行数:25,代码来源:Helper.java


注:本文中的android.provider.ContactsContract.PhoneLookup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。