Android更改联系人图片
我正在构建一个应用程序,当单击图像时,用户会看到联系人列表并选择一个。单击后,其联系人图片应更改为首先单击的图像。 这是我的实现方式:
....
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, SELECT_CONTACT);
.....
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_CONTACT) {
Uri contactData = data.getData();
????? what should come here???
}
}
}
我的问题是如何访问和更改联系人图片? 谢谢
I'm building an app where when a image is clicked the user sees the contacts list and picks one. After clicking on it, it's contact picture should change to the image clicked in the first place.
Here's how i implement it:
....
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, SELECT_CONTACT);
.....
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_CONTACT) {
Uri contactData = data.getData();
????? what should come here???
}
}
}
My question is how do i acces and change the contact picture?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,获取联系人第一个原始联系人的 Uri:
然后,将位图转换为字节数组:
最后,将字节数组设置为原始联系人的照片:
编辑
请务必将这两个权限包含在您的清单:
First, get the Uri for the Contacts first raw contact:
Then, convert a bitmap to a byte array:
Finally, set the byte array as the raw contact's photo:
EDIT
Be sure to include these two permissions in your manifest: