问题描述
我想补充的list.I很能没有传递,名称和其他细节successfully.I现在所面临的问题与配置文件pic.How接触来传递一个配置文件PIC联系人的Android通讯录中的联系人?
I want to add a contact in the android contacts list.I am able to pass the contact no,name and other detail successfully.I am facing problem with the profile pic.How to pass a profile pic for the contact ?
推荐答案
您必须使用在传统的插入ContactsContract.CommonDataKinds.Photo 或使用的并提供照片(作为一个字节数组为例)。刚参阅一些例子。
You have to use ContactsContract.CommonDataKinds.Photo in your traditional insert or using ContentProviderOperation and also provide the photo (as a byte array for example). Just refer to the official doc for some examples.
基本上,code使用ContentValues看起来是这样的:
Basically the code with using ContentValues will look something like:
ContentValues values = new ContentValues();
values.put(ContactsContract.Data.RAW_CONTACT_ID, contactId);
values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, photoByteArray);
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE );
使用ContentProviderOperation中,code将类似于:
Using ContentProviderOperation, the code will look similar to:
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE,photoByteArray).build();
这篇关于添加在android系统联系人照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!