为什么联系人不会聚合? [英] why won't contacts aggregate?

查看:19
本文介绍了为什么联系人不会聚合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用允许编辑联系人.在这种情况下,我选择了一个仅存在于一个帐户中的联系人并将其更改为与三个帐户相关联.但是,我最终得到了两个联系人,而不是一个,如下面的 ContactsContract 转储所示.提供商为什么不汇总它们?

My app allows editing contacts. In this scenario, I chose a contact which existed in only one account and changed it to associate it with three accounts. However, I ended up with two contacts, not one, as shown in the ContactsContract dump below. Why didn't the provider aggregate them?

agg 1821, display "A Z1", key 770i236434918d3893ea.2709i79dde86f8c1565d3.2709i506dc01a0d43d677.2709i4707c358f8fb503
  raw 1821, acct type com.google, acct name a@gmail.com
    data 10338, display "A Z1"
    data 10343, phone 123456, Pager
    data 10349, phone 545, Fax Work

agg 1861, display "A Z1", key 1780r1860-q29pq04pq5Bpq16p.2709r1861-q29pq04pq5Bpq16p
  raw 1860, acct type com.fusionone.account, acct name Backup Assistant
    data 10580, display "A Z1"
    data 10582, phone 123456, Pager
    data 10584, phone 545, Fax Work

  raw 1861, acct type com.google, acct name b@gmail.com
    data 10581, display "A Z1"
    data 10583, phone 123456, Pager
    data 10585, phone 545, Fax Work

在此转储中,三层代表聚合联系人行、原始联系人行和联系人数据行.前导词旁边的数字(例如 agg 1821)是 _ID 列值.display"代表DISPLAY_NAME.

In this dump, the three tiers represent the aggregate contact rows, the raw contact rows, and the contact data rows. The number next to the leading word (e.g. agg 1821) is the _ID column value. "display" represents DISPLAY_NAME.

更具体地说,我从账户 a@gmail.com(混淆)中的 agg 1821 开始.然后我为另外两个帐户创建了两个新的原始联系人(1860 和 1861),使用与 agg 1821 相同的显示名称.您可以看到结果:两个新的原始联系人聚合在一起,但该对未与原始联系人聚合(1821) 联系方式.

More specifically, I started with agg 1821 which comes from account a@gmail.com (obfuscated). Then I created two new raw contacts (1860 and 1861) for two other accounts, using the same display name as for agg 1821. You can see the results: the two new raw contacts were aggregated together but the pair was not aggregated with the original (1821) contact.

推荐答案

如果您希望 RawContacts 通过写入 AggregationExceptions:

Don't assume the system to aggregate similar contacts, if you want RawContacts to join force aggregation by writing to AggregationExceptions:

对于每一对,创建一个操作:

for each pair, create an operation:

Builder builder = ContentProviderOperation.newUpdate(AggregationExceptions.CONTENT_URI);
builder.withValue(AggregationExceptions.TYPE, AggregationExceptions.TYPE_KEEP_TOGETHER);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, raw1);
builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, raw2);
ContentProviderOperation op = builder.build();

然后执行一个ArrayList的所有操作:

Then execute an ArrayList of all operations:

ContentProviderResult[] res = resolver.applyBatch(ContactsContract.AUTHORITY, operationList);

res 将包含有关所有操作成功/失败的信息

res will contain info about the success/failure of all operations

这篇关于为什么联系人不会聚合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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