我正在尝试阅读联系人有问题,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();
答案 0 :(得分:0)