سؤال

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?

هل كانت مفيدة؟

المحلول 2

نصائح أخرى

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;
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top