I'm having problems getting and setting a contact's image as a view's background, surprisingly there are few examples on how to do it. I'm trying to build something similar to the People app which displays big contact photos.
This is what I'm doing right now:
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.valueOf(id));
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(context.getContentResolver(), uri);
Bitmap bm = BitmapFactory.decodeStream(input);
Drawable d = new BitmapDrawable(bm);
button.setBackgroundDrawable(drawable);
This works however the URI it uses gets a thumbnail picture, so even if there is a big photo images looks very bad when scaled to fit the imageView. I know another method to get the URI that actually gets a big photo which is:
final Uri imageUri = Uri.parse(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_URI)));
However I haven't managed to get it to the imageView, maybe the code above can be adapted to use the second uri. If you know how to use the second uri or if there is an easier way to get the contact image than through the URI please tell me. Any info will be thanked.