我想从联系人中挑选照片。我从 stack overflow 得到了以下代码,但是我需要为该方法传递哪些参数?请帮助我
public static Bitmap loadContactPhoto(ContentResolver cr, long id) {
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
if (input == null) {
return null;
}
return BitmapFactory.decodeStream(input);
}
最佳答案
我不知道你是否从同一个链接引用,但你可以引用this .
我没试过这个。但是引用这个链接,我认为,你必须传递 ContactsContract.Contact 表的 _id。
Cursor cursor=getContentResolver.query(ContactsContract.Contacts.CONTENT_URI,null,null,null,null);
cursor.moveToFirst();
long id=cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
loadContactPhoto(getContentResolver(),id)
应该作为参数传递到这里。
关于android - 从联系人中选择照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7991540/