如何在Android中以编程方式加入2个联系人? [英] How can I programmatically join 2 contacts in android?
问题描述
我需要知道是否有可能加入两个或多个联系人(以编程方式,使用Contacts android API或其他方式).
I need to know if is it possible to join two or more contacts (in a programmatic way, using the Contacts android API or something).
例如,我有一个具有电子邮件帐户和电话号码的联系人"Axel Rose", 而且我注意到,诸如whatsapp,Facebook和Skype之类的某些应用程序正在为Axel Rose创建新的联系人条目,而不是合并现有的联系人条目.
For example, I have a contact "Axel Rose" with an email account and a phone number, and I've noticed that some apps like whatsapp, Facebook and Skype are creating new contact entries for Axel Rose, instead of merging the existing one.
我可以使用手机上的加入功能"来加入联系人,但是有编程方式吗?
I can join contacts using the "Join feature" from the phone, but is there a programmatic way?
预先感谢.
克里斯蒂安.
Thanks in advance.
Cristian.
推荐答案
您可以使用如何手动汇总联系人?
您在电话簿中看到的联系人就是ContactsContract.Contacts表中的联系人.电话簿中显示的照片,电话等来自不同的RawContacts条目.一个联系人可以有一个或几个RawContacts.
The contacts that you see on your phonebook are the ones on the ContactsContract.Contacts table. The photo, phone, etc shown on the phonebook comes from different RawContacts entries. A contact can have one o several RawContacts.
当RawContacts共享一些常用数据(姓名,电话号码,电子邮件等)时,一个Contact碰巧有多个RawContact.通过自动聚合规则将此RawContacts合并为单个Contact(请参见
A Contact happens to have several RawContact when the RawContacts share some data on common (name, phone number, email, etc). The union of this RawContacts into a single Contact is made by automatic aggregation rules (see Contact Basics docs).
您不能在ContactsContract.Contacts表中插入联系人. 从文档中:
You can't insert contacts on the ContactsContract.Contacts table. From the documentation:
注意:如果您尝试使用insert()将联系人添加到联系人提供程序,则会收到UnsupportedOperationException异常.如果您尝试更新列为只读"的列,则该更新将被忽略.
Note: If you try to add a contact to the Contacts Provider with an insert(), you'll get an UnsupportedOperationException exception. If you try to update a column that's listed as "read-only," the update is ignored.
这篇关于如何在Android中以编程方式加入2个联系人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!