本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}