2
嗨我想获取联系人的名字。我知道如何获得联系人的全名,但我无法弄清楚如何获取姓名。有任何想法吗?android获取联系人的名字
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()) {
String name = cur.getString(2);
// do something with the name
}
} finally {
cur.close();
}