I'm writing an application for SMS messaging and I want to show profile picture of all senders (it is not a problem) and picture of my profile for sent messages. The same implementation was done in native Messaging app. Could you please advice how I can get own profile picture?
Asked
Active
Viewed 793 times
2 Answers
4
I found a solution for my question:
public static Bitmap getProfilePhoto(Context context) {
Bitmap profilePhoto = null;
ContentResolver cr = context.getContentResolver();
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, ContactsContract.Profile.CONTENT_URI);
if (input != null) {
profilePhoto = BitmapFactory.decodeStream(input);
} else {
profilePhoto = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_contact_picture);
}
return profilePhoto;
}

pbelov
- 445
- 6
- 20
-
Works, i recomen use "true" in openContactPhoto for high res ;) InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, ContactsContract.Profile.CONTENT_URI,true); – Javier Aug 16 '13 at 23:24
0
Read up here http://developer.android.com/reference/android/provider/ContactsContract.Profile.html and then look into CursorLoader's and cursors, write one to query for the photo uri or photo thumbnail uri.
Update
I found similar questions that should help you
Get profile picture of specific phone number from contacts information
Get user/owner profile contact URI and user image with API 8 onwards