android - 小米 vivo 如何实现读取通讯录?
黄舟
黄舟 2017-04-17 17:08:26
0
4
891

普通数据库读取不可行,小米vivo管理允许读取通讯录后依旧不可行,其他品牌手机可以读取,求助可行读取办法,在线等。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(4)
洪涛

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));
....
} 
    

Finally, pay attention to adding permissions.

Peter_Zhu

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.

PHPzhong

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?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!