【问题标题】:Large Photo Version from contacts in android来自android中联系人的大照片版本
【发布时间】:2014-03-13 03:04:42
【问题描述】:

我正在尝试使用以下代码从我的联系人中获取更大尺寸的图片:

Uri my_contact_Uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(contactId));

       InputStream photo_stream = ContactsContract.Contacts.openContactPhotoInputStream(getContentResolver(), my_contact_Uri);

    if(photo_stream != null) 
    {
        BufferedInputStream buf =new BufferedInputStream(photo_stream);
        Bitmap my_btmp = BitmapFactory.decodeStream(buf);
        profile.setImageBitmap(my_btmp);
    }
    else
    {
        profile.setImageResource(R.drawable.contactpic);
    }

我有一个imageviewmatch_parent(宽度和高度)。

所有联系人的照片都是模糊的。我确定它正在拍摄缩略图。如何获得大图?

【问题讨论】:

    标签: android android-contacts


    【解决方案1】:

    你必须使用

    ContentResolver cr = getContext().getContentResolver();
    Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.valueOf(CONTACT_ID));
    InputStream photo_stream = ContactsContract.Contacts.openContactPhotoInputStream(cr, contactUri, true);
    

    如果不输入boolean参数,默认为false,返回缩略图视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多