vamsiampolu
vamsiampolu

Reputation: 6630

Android:Retrieving Image or Thumbnail from ContactsProvider for API level 10

I would like to retreive the full size Contact Image from the Android ContactsProvider for API level 10 and above.

From my understanding there is no way to test whether I get the full size photo using PHOTO_URI(API level 11) which seems to be populated either using the PHOTO_FILE_ID(API level 14).Then there is PHOTO_ID(API level 5) which could hold a reference to the photo or not,if not fallback to PHOTO_URI or PHOTO_THUMBNAIL_URI(API level 11).I use 2.3.3(API level 10).This is all confusing and perplexing.

I use DISPLAY_PHOTO(API level 14),it is gauranteed to give me a null value or crash below ICS(havent tested yet).

I also understand that some images from say 3rd party applications that sync with ContactsProvider cannot be retreived and are only for the use of the Android ContactsProvider which means that the user sees the image in the Contacts app of the phone but not in the my app.

Any solution you might know of that could help me always retreive the full size api and not the thumbnail for API level 10 and above?

Can I atleast retreive the thumbnail of the Contact for API level 10?

Upvotes: 3

Views: 770

Answers (1)

vamsiampolu
vamsiampolu

Reputation: 6630

I found a method on this post that works for obtaining the thumbnail for API levels 5 and above using the ContactsContract API,check here for more information:

    public static Bitmap loadContactPhoto(ContentResolver cr, long id) {
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
if (input == null) {
     return getBitmapFromURL("http://thinkandroid.wordpress.com");
 }
return BitmapFactory.decodeStream(input);
} 

Upvotes: 2

Related Questions