Android:以编程方式更新的联系人未与其他应用同步 [英] Android :Programmatically updated contact is not syncing with other apps

查看:99
本文介绍了Android:以编程方式更新的联系人未与其他应用同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用批量操作"context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);"更新联系人时,其他应用程序(如WhatsApp)不会自动进行更新.

When a contact is updated with batch operation "context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);" then other apps like WhatsApp does not take updates automatically.

例如,如果手机号码被更新/删除为:-

For example, If mobile number is updated/removed as:-

String deviceNumber= "+1 (234) 56789";
String oldTrimmed= "+123456789";

  String where = ContactsContract.CommonDataKinds.Phone.NUMBER + " = ? OR " + ContactsContract.CommonDataKinds.Phone.NUMBER + " = ? AND " + ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
        String[] args = {oldTrimmed, deviceNumber, contactId, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE};
        ArrayList<ContentProviderOperation> ops = new ArrayList<>();
        ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI)
                .withSelection(where, args)
                .build()
        );

然后,旧号码仍在手机中显示为whatsApp号码.

then old number is still displayed in mobile as whatsApp number.

是否有任何方法可以在更新后触发移动通讯录的同步,以便其他应用程序也可以自动同步.

Is there any way to trigger sync for mobile contacts after any updation sothat other apps can be also synced automatically.

推荐答案

Whatsapp不是基于联系人"而是基于电话号码",这意味着如果您更改联系人A的电话号码,则不会更改现有对话与该联系人联系(因为该对话的关键"是电话号码).

Whatsapp is not "contact-based" rather "phone-number-based" meaning that if you change Contact A's phone number, it will NOT change the existing conversation with that contact (as that conversation's "key" is the phone number).

还请注意,您可以使用完全不存储在本地联系人中的电话号码进行通话.

Also note that you can have conversations with phone-numbers that are not stored in your local contacts at all.

Whatsapp与大多数其他应用一样,其 SyncAdapter 读取/写入Android Contacts数据库后,每个应用程序都可以决定是否希望将其唤醒并在发生更改时进行同步. 据我所知,Whatsapp不会唤醒并同步每个更改,而是定期执行,并且可以由用户手动触发(撰写新消息>菜单>刷新)

Whatsapp has its SyncAdapter like most other apps that read/write to the Android Contacts DB, each app can decide whether it wants to be woken up and sync whenever a change happens. Whatsapp, as far as I'm aware, does not wake up and sync each change, it does that periodically instead, and can be triggered manually by the user (compose new message > menu > refresh)

总结一下,如果您更新后的联系人 与其他应用同步,但按照 他们的 条款,你的.

So to sum if up your updated contact is syncing with other apps, but on their terms not yours.

这篇关于Android:以编程方式更新的联系人未与其他应用同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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