我正在尝试使用联系人 ID 获取联系人图像。
这是我的代码:-
public Bitmap getDisplayPhoto(Long id)
{
Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI,id);
InputStream input = Contacts.openContactPhotoInputStream(this.getContentResolver(), uri);
if (input == null)
{
return null;
}
return BitmapFactory.decodeStream(input);
}
此代码为我的所有联系人返回 null,包括那些有图像的联系人。
我做错了什么?
请帮忙!!
谢谢。
最佳答案
您的联系人是否从 Facebook 同步?因为这些似乎无法访问。
如果不是这样,您可能想试试这个:
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(this.getContentResolver(), uri);
不确定您是否已导入 ContactsContract
。
关于Android - 无法获取联系人照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6201854/