1
コードはMoto、Samsung、Huawiなどの他のデバイスで動作していますが、LG-D855(LG-G3) 。一部のデバイスは、サードパーティのアプリから連絡先を読めるようにいけないので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();
まだ連絡先を読むことができません。 – Shivang