【问题标题】:Need photo of each contact in the phonebook需要电话簿中每个联系人的照片
【发布时间】:2013-05-31 21:27:40
【问题描述】:

在获取与存储在地址或电话簿中的联系人相关的照片时,我感到非常困惑。 我找到的只是 ContactsContract.CommonDataKinds.Phone.CONTENT_URI 并从中获取光标。 并使用此光标获取有关特定联系人的所有详细信息。但它并没有给我与该联系人的照片。

我也尝试过 ContactsContract.CommonDataKinds.Photo.PHOTO ,每次都会加载空白位图。

谁能给我明确的方法来获取联系人的照片。

【问题讨论】:

    标签: android android-contentprovider android-contacts


    【解决方案1】:

    假设您有联系人的 ID,代码将如下所示:

         Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
         InputStream inStream = ContactsContract.Contacts.openContactPhotoInputStream(ctx.getContentResolver(), contactUri);
         }
         Bitmap bm = null;
         if (inStream != null) {
            bm = BitmapFactory.decodeStream(inStream);
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-01
      • 2014-02-09
      • 1970-01-01
      • 1970-01-01
      • 2014-02-07
      • 1970-01-01
      相关资源
      最近更新 更多