开发者

How to get the contact's display name in sms uri?

开发者 https://www.devze.com 2023-01-28 05:51 出处:网络
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 pe

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消