How do I get my custom account type to show up in the android contacts app?
Asked Answered
I

1

8

I've created a custom account type and I can successfully create contacts of that type in the android ContactsContract ContentProvider. But I'm having a lot of trouble figuring out how to get my custom account label and icon to show up when editing the contact in the default contacts app.

When editing a custom contact type, the label should be something like " contact", with your app's icon to the right. Instead, editing contacts of my type always show a label of "Phone-only, unsynced contact". See the first screenshot below for an example.

The weird thing is that it does pick up my account name, which you can see in the screenshot underneath the incorrect label (it starts with "+1415").

And I have successfully shown my app's label and icon in the settings app under accounts, so I know I'm doing something right. See the second screenshot below for proof of that (the account label is "Bolt").

Editing a custom contact in the Android contacts app Settings 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 anyone point me to where I'm going wrong with this? I can provide more info as necessary. I've tried creating the contact from within my SyncAdapter using the CLIENT_IS_SYNCADAPTER parameter but that didn't change anything. I've tried a few other things as well but nothing's worked yet.

Italianize answered 9/1, 2014 at 4:25 Comment(0)
I
4

I finally figured out what the issue was.

In my sync-adapter element the android:contentAuthority attribute was set to a custom content authority for my own contacts ContentProvider, which is technically what I use to query and write contact data. But it turns out to get your contacts to show up in the default contacts app this attribute must be set to "com.android.contacts".

Italianize answered 13/1, 2014 at 3:5 Comment(2)
Are your synced contacts still displaying as "phone-only, unsynced contact"? Because when I changed the android:contentAuthority declaration for my SyncAdapter per your answer, I was finally able to see my account type in the Contacts app, but contacts which were synced from my app were still being marked in the Contacts app as "phone-only, unsynced".Matronize
I didn't think this was still a problem, but just to be sure I checked and confirmed that my contacts no longer show "phone-only, unsynced contact". Perhaps this is to do with using CLIENT_IS_SYNCADAPTER when I insert/update?Italianize

© 2022 - 2024 — McMap. All rights reserved.