New contacts created using ContactsContract do not appear in Contacts app

后端 未结 4 1269
感动是毒
感动是毒 2020-12-03 09:33

I\'m using the following piece of codes to create a new contact. It follow closely the ContactManager example provided by Android. The problem is, the created contacts do n

4条回答
  •  一向
    一向 (楼主)
    2020-12-03 10:12

    To add an account in emulator that has no groups or accounts, just put "null" as your account or group id, replace the line of code like this

    ops.add(ContentProviderOperation
        .newInsert(ContactsContract.RawContacts.CONTENT_URI)
        .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)  
        .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
        .build());
    

提交回复
热议问题