Reputation: 110620
Can you please tell me how can I get the photo data if I have a list of photo_ids?
I try this:
cursor = mResolver.query(Contacts.Photos.CONTENT_URI, null, "_id IN (?)" , new String[] {"458"}, null);
But the cursor return null.
Any idea How to troubleshoot?
Thank you.
Upvotes: 2
Views: 909
Reputation: 3939
The new api is
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(cr, photo);
Upvotes: 1
Reputation: 82355
You can use the static method loadContactPhoto
to grab the photo for a contact..
Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, 458);
Bitmap contactPhoto = People.loadContactPhoto(_context, uri, R.drawable.unkown_contact, null);
if (null != contactPhoto) {
/* Your Magic Here */
}
Just to note, you will likely want to replace R.drawable.unkown_contact
with a resource you have for non-existent contact photos as well as replace _context
with an instance of a Context that you have.
Upvotes: 1