无法以编程方式阅读Android LG-D855(LG-G3)

时间:2016-05-20 14:55:12

标签: android android-contacts lg

我正在尝试阅读联系人有问题,Code正在其他设备上工作,如Moto,Samsung,Huawi,但不适用于LG-D855(LG-G3)。 这是我的代码:

char lastChar = ' ';
    ArrayList<PhoneContact> phoneContacts = new ArrayList<>();
    ContentResolver cr = activity.getContentResolver();
    String[] PROJECTION = new String[]{ContactsContract.RawContacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME,
            ContactsContract.Contacts.PHOTO_ID,
            ContactsContract.CommonDataKinds.Email.DATA,
            ContactsContract.CommonDataKinds.Photo.CONTACT_ID};
    String order =  ContactsContract.Contacts.DISPLAY_NAME
            + " COLLATE NOCASE ";

    String filter = ContactsContract.CommonDataKinds.Email.DATA + " NOT LIKE ''";
    Cursor cur = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, PROJECTION, filter, null, order);
    PhoneContact phoneContact;
    if (cur.moveToFirst()) {
        do {
            // names comes in hand sometimes
            String name = cur.getString(1);
            String emailAddress = cur.getString(3);

            char firstChar = name.toLowerCase().charAt(0);
            phoneContact = new PhoneContact(name, emailAddress);

            phoneContacts.add(phoneContact);
        } while (cur.moveToNext());
    }

    cur.close();

1 个答案:

答案 0 :(得分:0)

请检查手机权限以阅读联系人,因为某些设备不允许阅读第三方应用的联系人。

以下是小米手机的链接,无法在Whatsapp手机中显示。

enter link description here