开发者

Android Contacts Access

开发者 https://www.devze.com 2023-03-24 11:33 出处:网络
Uri contactUri = ContactsContract.Contacts.CONTENT_URI; String[] PROJECTION = new String[] { Contacts._ID,
Uri contactUri = ContactsContract.Contacts.CONTENT_URI;
        String[] PROJECTION = new String[] 
        {
           Contacts._ID,
           Contacts.DISPLAY_NAME,
           Contacts.HAS_PHONE_NUMBER,
        };
        String SELECTION = ContactsContract.Contacts.HAS_PHONE_NUMBER + "='1'";
    Cursor contacts = getContentResolver().query(contactUri, PROJECTION, null, null, null);

here is a piece of code when i comment out last line it works and when i use it it gives the message the process (package name) is stopped unexpectedly. u use permi开发者_JAVA技巧ssion of reading contacts in mainifiest file.


Sorry the question is not clear . Yes you have to include the following permissions to read the contacts .

  <uses-permission android:name="android.permission.READ_CONTACTS"/>
0

精彩评论

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

关注公众号