Android联系人聚合过程 [英] Android contacts aggregation process

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

问题描述

我无法在Android联系人中找到有关聚合过程的详细信息.我知道 ContactsContract.Contacts -> ContactsContract.RawContacts -> ContactsContract.Data 结构(如

I'm unable to find detailed information about the aggregation process in Android's contacts. I'm aware of the ContactsContract.Contacts -> ContactsContract.RawContacts -> ContactsContract.Data structure (as described on http://developer.android.com/guide/topics/providers/contacts-provider.html), and that a Contact consists of Raw Contacts, which are grouped together through one Contact_ID.

我特别想知道的是:在什么情况下将原始联系人分组为一个联系人?

What I specifically want to know is: under what circumstances are Raw Contacts grouped into one Contact?

我发现了这个问题和答案-特别是最后一个选项:

I found this question and answer - specifically the last option:

两个原始联系人中至少有一个完全缺少姓名,并且他们共享电话号码,电子邮件地址或昵称(例如, Bob Parr [incredible@android.com] =令人难以置信的@android.com ).

我尝试了一下,但是似乎没有用.我想知道是否可以将原始联系人添加到本地联系人,并 仅设置 ACCOUNT_TYPE ACCOUNT_NAME 和电话或电子邮件地址,并且如果该联系人的电话号码或电子邮件地址已经存在,则自动将其与原始联系人进行汇总.例如:

I tried this out, however, it doesn't seem to work. I want to know if I can add a Raw Contact to the local contacts and set only the ACCOUNT_TYPE, ACCOUNT_NAME and phone or emailaddress, and if this will be automatically aggregrated with a raw contact for whom this phone number or emailaddress already exists. So for example:

( ContactsContract.Contacts.) _ID (类似于 ContactsContract.RawContacts.Contact_ID ):1188300包含:

(ContactsContract.Contacts.)_ID (Similar to ContactsContract.RawContacts.Contact_ID): 1188300 consists of:

  • 原始联系人ID 20905
    MIMETYPE = \ email_v2
    ACCOUNT_TYPE = com.google
    NAME =示例测试
    EMAIL = test@gmail.com
  • 原始联系人ID 20897
    MIMETYPE = \ phone_v2
    ACCOUNT_TYPE = com.google
    NAME =示例测试
    EMAIL = 123456
  • Raw Contact ID 20905
    MIMETYPE = \email_v2
    ACCOUNT_TYPE = com.google
    NAME = Example Test
    EMAIL = test@gmail.com
  • Raw Contact ID 20897
    MIMETYPE = \phone_v2
    ACCOUNT_TYPE = com.google
    NAME = Example Test
    EMAIL = 123456

添加以下内容后:

  • 原始联系人
    MIMETYPE = \ email_v2
    ACCOUNT_TYPE = com.exampleApp EMAIL = test@gmail.com

这将导致以下结果: ( ContactsContract.Contacts.) _ID :1188300包括:

will this result into: (ContactsContract.Contacts.)_ID: 1188300 consisting of:

  • 原始联系人ID 20905
    MIMETYPE = \ email_v2
    ACCOUNT_TYPE = com.google
    NAME =示例测试
    EMAIL = test@gmail.com
  • 原始联系人ID 20897
    MIMETYPE = \ phone_v2
    ACCOUNT_TYPE = com.google
    NAME =示例测试
    EMAIL = 123456

原始联系人ID 20899(或任何数字)
MIMETYPE = \ email_v2
ACCOUNT_TYPE = com.exampleApp
NAME =示例测试
EMAIL = test@gmail.com

Raw Contact ID 20899 (or whatever number)
MIMETYPE = \email_v2
ACCOUNT_TYPE = com.exampleApp
NAME = Example Test
EMAIL = test@gmail.com

推荐答案

联系人聚合由做什么是将每个原始联系人与其他原始联系人进行匹配,聚合是根据

What is does is match every raw contact with other raw contacts, the aggregations is done based on a score generated by RawContactMatcher

该文件包含一些解释,但是您可以检查为不同参数分配的分数,以及匹配的分数(精确,保守和近似).

The file contains a little explanation, but you can check the score assigned for different parameters and also the matching scores (EXACT, CONSERVATIVE and APPROXIMATE).

名称示例-

/**
 * Name matching scores: a matrix by name type vs. candidate lookup type.
 * For example, if the name type is "full name" while we are looking for a
 * "full name", the score may be 99. If we are looking for a "nickname" but
 * find "first name", the score may be 50 (see specific scores defined
 * below.)
 * <p>
 * For approximate matching, we have a range of scores, let's say 40-70.  Depending one how
 * similar the two strings are, the score will be somewhere between 40 and 70, with the exact
 * match producing the score of 70.  The score may also be 0 if the similarity (distance)
 * between the strings is below the threshold.
 * <p>
 * We use a string matching algorithm, which is particularly suited for
 * name matching. See {@link NameDistance}.
 */

如果要将两个联系人汇总(合并),只需在

If you want two contacts to be aggregated(Joined) just add an entry in http://developer.android.com/reference/android/provider/ContactsContract.AggregationExceptions.html with type as TYPE_KEEP_TOGETHER

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

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