Load Contact Image Into Bitmap

送分小仙女□ 提交于 2019-11-29 03:41:47

I dont think you should pass the uri of the photo to openContactphotoinputstream. You just need to pass the uri of the contact itself to get the bitmap.

 Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
  InputStream stream = ContactsContract.Contacts.openContactPhotoInputStream(
            mContext.getContentResolver(), uri);

Or if you are going to pass the contact photo uri then you could use

public static Bitmap getContactBitmapFromURI(Context context, Uri uri) {
        InputStream input = context.getContentResolver().openInputStream(uri)
        if (input == null) {
            return null;
        }
        return BitmapFactory.decodeStream(input);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!