2015-02-09 102 views
0

我正在嘗試構建將我的聯繫人與手機通訊錄(類似Google,Facebook,LinkedIn)合併在一起的應用程序。我在電話聯繫人列表中的應用程序聯繫人

我構建了同步適配器,並自動添加到帳戶中。我也有一個內容提供者和一個聯繫人表。 我遵循以下主題How to make a custom account show up like Google/LinkedIn/Facebook in the native Contacts app?

所以,我有我自己的uri和聯繫人表。 在這裏,我不知道如何將項目從我的表與手機通訊錄

回答

0

鏈接閱讀其他許多討論之後只是我需要:

烏里myUri = uri.buildUpon()appendQueryParameter(ContactsContract。 .CALLER_IS_SYNCADAPTER, 「真」)建()。

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);

相關問題