Android的 - 取得联系全尺寸图片 [英] Android - Get contact full-size image
问题描述
我想给一个联系人的ID来获得联系人的完整大小的图片,我想出了这一点:
I'm trying to get a contact's full-size image given a contact id, I came up with this :
private Bitmap getUserPhoto(long contactId) {
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI,
contactId);
Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
Contacts.Photo.DISPLAY_PHOTO);
try {
AssetFileDescriptor fd = getContentResolver()
.openAssetFileDescriptor(displayPhotoUri, "r");
return BitmapFactory.decodeStream(fd.createInputStream());
} catch (IOException e) {
return null;
}
}
但图像尺寸太小(缩略图)
but the image size is too small (Thumbnail)
我怎样才能得到一个联系人的全尺寸照片么?
how can I get the full-size photo of a contact?
感谢
推荐答案
您可以使用<一个href=\"http://developer.android.com/reference/android/provider/ContactsContract.Contacts.html#openContactPhotoInputStream%28android.content.ContentResolver,%20android.net.Uri,%20boolean%29\"相对=nofollow> openContactPhotoInputStream(ContentResolver的CR,乌里contactUri,布尔preferHighres),如果您的手机中有原始图像。并设置preferHighres TRUE。
You can use openContactPhotoInputStream(ContentResolver cr, Uri contactUri, boolean preferHighres), if you have original image in your phone. And set preferHighres TRUE.
这篇关于Android的 - 取得联系全尺寸图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!