當前位置: 首頁>>代碼示例>>Java>>正文


Java PhoneLookup.LOOKUP_KEY屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:16,代碼來源:ContactAccessor.java

示例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;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:23,代碼來源:ContactIdentityManagerGingerbread.java

示例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;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:25,代碼來源:ContactIdentityManagerICS.java

示例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;
}
 
開發者ID:ProjectMAXS,項目名稱:maxs,代碼行數:27,代碼來源:ContactUtil.java

示例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;
}
 
開發者ID:gabuzomeu,項目名稱:geoPingProject,代碼行數:31,代碼來源:ContactHelper.java

示例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();
}
 
開發者ID:ProjectMAXS,項目名稱:maxs,代碼行數:32,代碼來源:ContactUtil.java


注:本文中的android.provider.ContactsContract.PhoneLookup.LOOKUP_KEY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。