Domanda

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?

È stato utile?

Soluzione 2

Altri suggerimenti

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;
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top