private String[] getPhoneContacts(Uri uri) {
String[] contact = new String[2];
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(uri, null, null, null, null);
if (cursor != null && cursor.getCount()>0 &&cursor.moveToFirst()) {
int nameFieldColumnIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
contact[0] = cursor.getString(nameFieldColumnIndex);
String ContactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Cursor phone = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + ContactId, null, null);
if (phone!=null && phone.getCount()>0) {
while(phone.moveToNext()){
contact[1] = p
通过Uri获取手机通讯录的某个联系人
最新推荐文章于 2021-06-23 15:32:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)