如何更改联系人图片progmatically我选择它的接触? [英] how to change contact picture progmatically which contact i select.?

查看:222
本文介绍了如何更改联系人图片progmatically我选择它的接触?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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"/>

和的这个能有所帮助。

这篇关于如何更改联系人图片progmatically我选择它的接触?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆