I wrote following method to get photo by Contact Id:
private String getPhotoStringFromDevice( String contactId){
String photoString = "none";
String tmpPhotoString = "";
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.valueOf(contactId));
Uri photoUri = Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
ContentResolver cr = mContext.getContentResolver();
Cursor c = cr.query(photoUri, new String[] {ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
if (c.moveToFirst()) {
byte[] photoBytes = c.getBlob(0);
photoString = Base64.encodeToString(photoBytes, Base64.DEFAULT);
}
c.close();
return photoString;
}
However I have only email and don't have ability (performance issues) to run on all contacts to fetch contactId by email.
Is there any way to get photo by email?
Thanks,
Aucun commentaire:
Enregistrer un commentaire