Using the Uri provided by ContentResolver and ContentProvider, you can obtain the address book in the system Management contact Uri: ContactsContract.Conacts.CONTENT_URI Phone Uri: ContactsContract.CommonDataKinds.Phone.CONTENT_URI
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null,null,null,null);
//遍历结果
if (cursor.moveToNext()){
//联系人ID
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
//联系人名字
String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
....
}
If you use ContentProvider, it will be the same for every platform. Mobile phone manufacturers cannot change it casually because the mobile phone will go through the CTS process before it is launched. So if it doesn't work on your side, it's probably because there's something wrong with the code.
Xiaomi and vivo are not the same brand. We can read Xiaomi's address book, but we don't have a vivo test machine. Are you referring to Xiaomi vivo being unable to read?
Using the Uri provided by ContentResolver and ContentProvider, you can obtain the address book in the system
Management contact Uri: ContactsContract.Conacts.CONTENT_URI
Phone Uri: ContactsContract.CommonDataKinds.Phone.CONTENT_URI
Finally, pay attention to adding permissions.
The answer above is correct, don’t forget to turn off cursor at the end
If you use ContentProvider, it will be the same for every platform. Mobile phone manufacturers cannot change it casually because the mobile phone will go through the CTS process before it is launched. So if it doesn't work on your side, it's probably because there's something wrong with the code.
Xiaomi and vivo are not the same brand. We can read Xiaomi's address book, but we don't have a vivo test machine. Are you referring to Xiaomi vivo being unable to read?