Update existing contact with image in Android

自闭症网瘾萝莉.ら 提交于 2019-12-11 10:54:10

问题


I am able to update image in contact from my app and its visible in contacts but as soon as google sync occurs it deletes the image from contact.

My code:

ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
    .withValue(ContactsContract.Data.RAW_CONTACT_ID, lRawContactId)
    .withValue(ContactsContract.Data.IS_PRIMARY, 1)
    .withValue(ContactsContract.Data.IS_SUPER_PRIMARY, 1)
    .withValue(ContactsContract.Data.MIMETYPE, 
               ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
    .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO,
               getImageByteArray(bitmap))
    .build());

回答1:


That's probably because you only set the thumbnail of the photo. Please see my response in Changing contact's image to a large photo via PHOTO_FILE_ID in Android to see how you should add or update a contact photo.



来源:https://stackoverflow.com/questions/37209954/update-existing-contact-with-image-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!