我需要我的联系人的联系人图像作为位图。
我找到了这段代码:
Uri my_contact_Uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(id));
InputStream photo_stream = ContactsContract.Contacts.openContactPhotoInputStream(cr, my_contact_Uri, true);
BufferedInputStream buf = new BufferedInputStream(photo_stream);
Bitmap my_btmp = BitmapFactory.decodeStream(buf);
buf.close();
return my_btmp;
效果很好,但是函数 openContactPhotoInputStream(cr, my_contact_Uri, true) 仅在 API 14+ 上可用。openContactPhotoInputStream(cr, my_contact_Uri) 也适用于早期版本,但没有第三个参数,它似乎只检索缩略图。
在文档中它说:
See Also
if instead of the thumbnail the high-res picture is preferred
但是此注释后面的链接似乎再次指向当前页面
我可以得到图像的 uri,但那又如何呢?