I have a listview
adapter and I\'m trying the following in the newView
method:
@Override
public View newView(Context context, C
Probably will help someone. Just leave it here.
This way you can get thumbnail uri by contact id.
Tested on Android API 28.
ContentResolver cr = getContentResolver();
String[] projection = new String[] {ContactsContract.Contacts.PHOTO_THUMBNAIL_URI};
String where = ContactsContract.Contacts.NAME_RAW_CONTACT_ID = "?";
String[] selectionArgs = {your_contact_id}
Cursor cur = cr.query(ContactsContract.Data.CONTENT_URI, projection, where, selectionArgs, null);
String thumbnailUri;
if ((cur != null ? cur.getCount() : 0) > 0) {
if (cur.moveToNext()) {
thumbnailUri = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI));
}
}
if(cur!=null){
cur.close();
}
return thumbnailUri;