Android的 - 取得联系全尺寸图片 [英] Android - Get contact full-size image

查看:169
本文介绍了Android的 - 取得联系全尺寸图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给一个联系人的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆