如何更改联系人图片progmatically我选择它的接触?它的、如何更改、联系人、图片

2023-09-03 22:54:00 作者:长发及腰肯定分叉不少

我不知道该。但我想这个计划我的项目?普莱舍帮助我。

i have no idea for that. but i want this program for my project.? plese help me.

感谢名单提前

推荐答案

您可以使用任何按钮里面以下code应用新的图像 onClickListener()或内部 onActivityResult()申请:

you can apply the new image using the following code inside any Button's onClickListener() or inside onActivityResult() to apply :

final ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
    .withSelection(Data._ID, dataId),
    .withValue(Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE),
    .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, byteArrayOfThePicture);

getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);

请确保您有在清单中所需的权限第一:

make sure you have the required permissions first in the manifest:

<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>

这和的这个能有所帮助。