I am trying to get the contact's display name from the sms uri. I should get the person's contact id if that person is in my contact list. But every time I got a Null as a respond which means the person is not in my contact list. But actually the person is in my contact list and shown in the message. So is there a way to get the person's display name from sms ur开发者_JS百科i?btw, I am using 2.2 emulator.
Uri personUri = Uri.withAppendedPath( ContactsContract.PhoneLookup.CONTENT_FILTER_URI, smsMsg.getOriginatingAddress());
cur = appContext.getContentResolver().query(personUri, new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null );
if( cur.moveToFirst() ) {
int nameIndex = cur.getColumnIndex(PhoneLookup.DISPLAY_NAME);
PersonName = cur.getString(nameIndex);
}
cur.close();
精彩评论