【问题标题】:Android contacts aggregation processAndroid联系人聚合过程
【发布时间】:2016-01-14 00:50:31
【问题描述】:

我无法在 Android 的联系人中找到有关聚合过程的详细信息。我知道ContactsContract.Contacts -> ContactsContract.RawContacts -> ContactsContract.Data 结构(如http://developer.android.com/guide/topics/providers/contacts-provider.html 所述),并且ContactRaw Contacts 组成,它们通过一个Contact_ID 组合在一起.

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

我找到了this 问题和答案——特别是最后一个选项:

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

我试过了,但是,它似乎不起作用。我想知道我是否可以将原始联系人添加到本地联系人并只设置ACCOUNT_TYPEACCOUNT_NAME 和电话或电子邮件地址,如果这将是自动与已存在此电话号码或电子邮件地址的原始联系人聚合。比如:

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

  • 原始联系人 ID 20905
    MIMETYPE = \email_v2
    ACCOUNT_TYPE = com.google
    NAME = Example Test
    EMAIL = test@gmail.com
  • 原始联系人 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 包括:

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

  • 原始联系人 ID 20899(或任何号码)
    MIMETYPE = \email_v2
    ACCOUNT_TYPE = com.exampleApp
    NAME = Example Test
    EMAIL = test@gmail.com

【问题讨论】:

    标签: android android-contacts


    【解决方案1】:

    联系人聚合由ContactAggregator2.java处理

    所做的是将每个原始联系人与其他原始联系人进行匹配,聚合是根据RawContactMatcher 生成的分数完成的

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

    名称示例-

    /**
     * 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}.
     */
    

    如果您想聚合(加入)两个联系人,只需在 http://developer.android.com/reference/android/provider/ContactsContract.AggregationExceptions.html 中添加一个类型为 TYPE_KEEP_TOGETHER 的条目

    【讨论】:

    • AggregationExceptions: 你只能更新这个,你不能为每个文档添加新条目
    猜你喜欢
    • 1970-01-01
    • 2021-01-06
    • 1970-01-01
    • 2017-04-02
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多