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


Java PhoneLookup.DISPLAY_NAME屬性代碼示例

本文整理匯總了Java中android.provider.ContactsContract.PhoneLookup.DISPLAY_NAME屬性的典型用法代碼示例。如果您正苦於以下問題:Java PhoneLookup.DISPLAY_NAME屬性的具體用法?Java PhoneLookup.DISPLAY_NAME怎麽用?Java PhoneLookup.DISPLAY_NAME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.provider.ContactsContract.PhoneLookup的用法示例。


在下文中一共展示了PhoneLookup.DISPLAY_NAME屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getContactsWithPush

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,代碼行數:23,代碼來源:ContactAccessor.java

示例2: 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

示例3: 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

示例4: 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

示例5: getContactsWithPush

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,代碼行數:23,代碼來源:ContactAccessor.java

示例6: getContactsWithPush

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,代碼行數:23,代碼來源:ContactAccessor.java

示例7: getContactsWithPush

public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = Directory.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:Securecom,項目名稱:Securecom-Text,代碼行數:23,代碼來源:ContactAccessor.java

示例8: contactExists

public boolean contactExists(Context context, String number) {
	// / number is the phone number
	Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
			Uri.encode(number));
	String[] mPhoneNumberProjection = { PhoneLookup._ID,
			PhoneLookup.NUMBER, PhoneLookup.DISPLAY_NAME };
	Cursor cur = context.getContentResolver().query(lookupUri,
			mPhoneNumberProjection, null, null, null);
	try {
		if (cur.moveToFirst()) {
			return true;
		}
	} finally {
		if (cur != null)
			cur.close();
	}
	return false;
}
 
開發者ID:saurabh2590,項目名稱:EasyAccess,代碼行數:18,代碼來源:TextMessagesViewerApp.java

示例9: getContactFromPhoneNumber

public static Contact getContactFromPhoneNumber(String phoneNumber, Context context) {
    Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
    final String[] contactProjection = new String[] {PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

    Cursor c = context.getContentResolver().query(contactUri, contactProjection, null, null, null);
    Contact contact = new Contact(phoneNumber, phoneNumber);

    try {
        if (c.moveToFirst()) {
            long id = c.getLong(c.getColumnIndex(PhoneLookup._ID));
            String name = c.getString(c.getColumnIndex(PhoneLookup.DISPLAY_NAME));

            contact = new Contact(id, phoneNumber, name);
        }
    } catch (Exception e) {
        Log.d(TAG, "Unable to retrieve contact with phone number " + phoneNumber);
    } finally {
        c.close();
    }

    return contact;
}
 
開發者ID:PhoneRemoteControl,項目名稱:OrbitCat,代碼行數:22,代碼來源:ContactUtils.java

示例10: 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

示例11: getContactName

public String getContactName(String phoneNumber) {
    Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
            Uri.encode(phoneNumber));
    String[] columns = { PhoneLookup.DISPLAY_NAME };
    String displayName = phoneNumber;
    Cursor cursor = getContentResolver().query(lookupUri, columns, null, null, null);
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            displayName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
        }
        cursor.close();
    }
    return displayName;
}
 
開發者ID:michalmazur,項目名稱:orphaned-texts-kitkat,代碼行數:14,代碼來源:OrphanedTextsActivity.java

示例12: get

public ArrayList<Contact> get() {
    Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    String[] projection = new String[] {
            PhoneLookup._ID,
            PhoneLookup.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.TYPE,
            ContactsContract.CommonDataKinds.Phone.LABEL,
            ContactsContract.CommonDataKinds.Phone.NUMBER
    };
    String[] simTypesQueryParts = new String[simTypes.length];
    Arrays.fill(simTypesQueryParts, ContactsContract.RawContacts.ACCOUNT_TYPE + " <> ?");
    String simTypesQuery = TextUtils.join(" AND ", simTypesQueryParts);
    String selection = ContactsContract.RawContacts.ACCOUNT_TYPE + " IS NULL OR (" + simTypesQuery + ")";
    String[] selectionArgs = simTypes;

    Cursor results = resolver.query(
            uri,
            projection,
            selection,
            selectionArgs,
            null
    );

    // create array of Phone contacts and fill it
    final ArrayList<Contact> phoneContacts = new ArrayList<>();
    int indexId = results.getColumnIndex(PhoneLookup._ID);
    int indexName = results.getColumnIndex(PhoneLookup.DISPLAY_NAME);
    int indexType = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
    int indexLabel = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
    int indexNumber = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
    while (results.moveToNext()) {
        int type = results.getInt(indexType);
        String custom = results.getString(indexLabel);
        final Contact phoneContact = new Contact(
                results.getString(indexId),
                results.getString(indexName),
                results.getString(indexNumber),
                (String) Phone.getTypeLabel(this.activity.getResources(), type, custom)
        );
        phoneContacts.add(phoneContact);
    }
    results.close();
    return phoneContacts;
}
 
開發者ID:yeriomin,項目名稱:DumbphoneAssistant,代碼行數:44,代碼來源:PhoneUtilEclair.java


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