문제

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