【问题标题】:My application contacts in the phone contacts list我的应用程序联系人在电话联系人列表中
【发布时间】:2015-02-09 13:40:30
【问题描述】:

我正在尝试构建一个应用程序,将我的联系人与电话联系人合并(类似于 Google、Facebook、LinkedIn)。

我构建了同步适配器并自动添加到帐户中。我还有一个带有联系人表的内容提供商。 我关注了以下主题How to make a custom account show up like Google/LinkedIn/Facebook in the native Contacts app?。

所以,我有自己的 uri 和联系人表。 从这里我不知道如何将我表中的项目与电话联系人联系起来

【问题讨论】:

    标签: android contacts


    【解决方案1】:

    在阅读了许多其他讨论之后,我只需要:

        Uri myUri = uri.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,"true").build();
    
        ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    
        ops.add(ContentProviderOperation.newInsert(uri)
                .withValue(RawContacts.ACCOUNT_NAME, ACCOUNT_NAME)
                .withValue(RawContacts.ACCOUNT_TYPE, ACCOUNT_TYPE)
                //.withValue(RawContacts.SOURCE_ID, 12345)
                //.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED)
                .build());
    
        resolver.applyBatch(ContactsContract.AUTHORITY, ops);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      • 2015-12-16
      • 2017-12-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      相关资源
      最近更新 更多