How can I customize the type of custom account in the Android contacts app?

I created my own type of account, and I can successfully create contacts of this type in the ContactsContract ContentProvider android. But I have a lot of problems figuring out how to get my own account shortcut and the icon that appears when editing a contact in the default contacts application.

When editing a custom contact type, the label should be something like “contact”, and the icon of your application on the right. Instead, when editing contacts of my type, the label "Phone only, unsynchronized contact" is always displayed. See the first screenshot below for an example.

It is strange that he takes away the name of my account, which you can see in the screenshot under the wrong label (it starts with "+1415").

And I successfully showed my app label and icon in the settings app under the accounts, so I know that I'm doing something right. See the second screenshot below to confirm this (account label is “Bolt”).

Editing a custom contact in the Android contacts appSettings app with custom account label and icon

I have the following authenticator.xml:

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android" android:accountType="@string/account_type" android:label="@string/app_name" android:icon="@drawable/app_icon" android:smallIcon="@drawable/app_icon" /> 

And this is my syncadapter.xml:

 <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentAuthority="@string/contacts_content_authority" android:accountType="@string/account_type" android:userVisible="true" android:allowParallelSyncs="false" android:isAlwaysSyncable="true" android:supportsUploading="false" /> 

Can someone point me where I am wrong? I can provide additional information as needed. I tried to create a contact from my SyncAdapter using the CLIENT_IS_SYNCADAPTER parameter, but did not change anything. I tried other things, but nothing worked.

+6
source share
1 answer

Finally, I realized what the problem is.

In my sync-adapter element, the android:contentAuthority was set to custom content for my own ContentProvider contacts, which I technically use to request and record contact details. But it turns out that your contacts should be displayed in the contacts application by default, this attribute should be set to "com.android.contacts" .

+3
source

All Articles