i am trying to fetch a contact image using contact id.
Here is my code :-
public Bitmap getDisplayPhoto(Long id)
{
Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI,id);
InputStream input = Contacts.openContactPhotoInputStream(this.getContentResolver(), uri);
if (input == null)
{
return null;
}
return BitmapFactory.decodeStream(input);
}
This code is returning null for all of my contacts including those which has an image.
What am i doing wrong here?
Please Help!!
Thanks.
Are your contacts synced from Facebook? Because those appear to not be accessible.
If that’s not the case, you may want to try this:
Wasn’t sure if you had the import for
ContactsContractin place.