0

我正在编写一个 SMS 消息传递应用程序,我想显示所有发件人的个人资料图片(这不是问题)和我的已发送消息的个人资料图片。在本机消息传递应用程序中完成了相同的实现。您能否建议我如何获得自己的个人资料图片?

4

2 回答 2

4

我为我的问题找到了解决方案:

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;
    }
于 2013-08-01T10:30:45.087 回答
0

在这里阅读 http://developer.android.com/reference/android/provider/ContactsContract.Profile.html 然后查看CursorLoader的和cursors,写一个来查询照片 uri 或照片缩略图 uri。

更新

我发现了应该对您有所帮助的类似问题

从联系人信息中获取特定电话号码的头像

使用 API 8 及更高版本获取用户/所有者个人资料联系人 URI 和用户图像

于 2013-08-01T09:45:59.163 回答