本文整理匯總了Java中android.provider.ContactsContract.PhoneLookup.LOOKUP_KEY屬性的典型用法代碼示例。如果您正苦於以下問題:Java PhoneLookup.LOOKUP_KEY屬性的具體用法?Java PhoneLookup.LOOKUP_KEY怎麽用?Java PhoneLookup.LOOKUP_KEY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.provider.ContactsContract.PhoneLookup
的用法示例。
在下文中一共展示了PhoneLookup.LOOKUP_KEY屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSystemContact
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;
}
示例2: getContactUriForNumber
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;
}
示例3: getSelfIdentityUri
@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;
}
示例4: contactByNumber
/**
* Lookup exactly one contact for a given number.
*
* @param number
* @return the contact, or null if none was found or the contactsread module is not installed.
*/
public Contact contactByNumber(String number) {
if (!contactsReadModuleInstalled()) return null;
number = ContactNumber.cleanNumber(number);
if (!ContactNumber.isNumber(number)) return null;
Uri uri = Uri.withAppendedPath(MAXS_PHONE_LOOKUP_CONTENT_FILTER_URI, Uri.encode(number));
final String[] projection = new String[] { PhoneLookup.LOOKUP_KEY, DISPLAY_NAME };
Cursor c = mContentResolver.query(uri, projection, null, null, null);
Contact contact = null;
if (c.moveToFirst()) {
String displayName = c.getString(c.getColumnIndexOrThrow(DISPLAY_NAME));
String lookupKey = c.getString(c.getColumnIndexOrThrow(PhoneLookup.LOOKUP_KEY));
contact = new Contact(displayName, lookupKey);
lookupContactNumbersFor(contact);
}
c.close();
return contact;
}
示例5: searchContactForPhone
/**
* <a href="http://developer.android.com/reference/android/provider/ContactsContract.PhoneLookup.html"> PhoneLookup</a>
*
* @param context
* @param phoneNumber
* @return
*/
public static ContactVo searchContactForPhone(Context context, String phoneNumber) {
String contactName = null;
long contactId = -1l;
if (isPermissionReadContact(context)) {
Log.d(TAG, String.format("Search Contact Name for Phone [%s]", phoneNumber));
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
final String[] selection = new String[]{ PhoneLookup._ID, PhoneLookup.LOOKUP_KEY, PhoneLookup.DISPLAY_NAME};
Cursor cur = context.getContentResolver().query(uri, selection, null, null, null);
try {
if (cur != null && cur.moveToFirst()) {
contactId = cur.getLong(cur.getColumnIndexOrThrow(PhoneLookup._ID));
contactName = cur.getString(cur.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
} finally {
cur.close();
}
}
Log.d(TAG, String.format("Found Contact %s Name for Phone [%s] : %s", contactId, phoneNumber, contactName));
ContactVo result = null;
if (contactId != -1l) {
result = new ContactVo(contactId, contactName);
}
return result;
}
示例6: contactsByNumber
/**
* Get all contacts for a given number
*
* @param number
* @return All contacts with that number.
*/
public Collection<Contact> contactsByNumber(String number) {
if (!contactsReadModuleInstalled()) return null;
number = ContactNumber.cleanNumber(number);
if (!ContactNumber.isNumber(number)) return null;
Uri uri = Uri.withAppendedPath(MAXS_PHONE_LOOKUP_CONTENT_FILTER_URI, Uri.encode(number));
final String[] projection = new String[] { PhoneLookup.LOOKUP_KEY, DISPLAY_NAME };
Cursor c = mContentResolver.query(uri, projection, null, null, null);
Map<String, Contact> contactMap = new HashMap<String, Contact>();
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
String displayName = c.getString(c.getColumnIndexOrThrow(DISPLAY_NAME));
String lookupKey = c.getString(c.getColumnIndexOrThrow(PhoneLookup.LOOKUP_KEY));
Contact contact = contactMap.get(lookupKey);
if (contact == null) {
contact = new Contact(displayName, lookupKey);
contactMap.put(lookupKey, contact);
lookupContactNumbersFor(contact);
}
}
c.close();
return contactMap.values();
}