Account doesn't appear in contacts app settings on device from HTC
Asked Answered
B

2

7

I write my own SyncAdapter based on example in SDK. It should add contacts from external source, and it works perfect in device emulator. But when I run it on HTC Desire after all I can't see my Account in Contacts->Display options

Also I tried google's example on Desire and couldn't see them in this list too. Does anyone know any solution?

Berardo answered 5/12, 2010 at 20:35 Comment(0)
B
6

I solve it by making my account visible by default.

ContentProviderClient client = getContentResolver().acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
ContentValues values = new ContentValues();
values.put(ContactsContract.Settings.ACCOUNT_NAME, account.name);
values.put(ContactsContract.Settings.ACCOUNT_TYPE, account.type);
values.put(ContactsContract.Settings.UNGROUPED_VISIBLE, true);
try
{
  client.insert(Settings.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build(), values);
}
catch (RemoteException e)
{
  e.printStackTrace();
}

after that account is visible by default, and you can see it in accounts list in contacts

Berardo answered 5/12, 2010 at 21:30 Comment(4)
Must this be called from the syncadapter?Mcneese
This does nothing in my situation.. Does it need to have at least one contact to show up?Mcneese
It worked in 2010 with HTC Desire. A lot of things changed since this time =)Berardo
Figured out what the problem was: I didn't use the ContactsContract.AUTHORITY_URI but my own autority. This works when you don't want to use groups.Mcneese
M
0

To make your account visible in "Display options" of standard Contacts application you should have SyncAdapter in your application and it's meta-data specified in syncadapter.xml as described here.

Moreover you should specify using of android.permission.WRITE_SYNC_SETTINGS permission in AndroidManifest.xml.

UNGROUPED_VISIBLE make it visible only for list of contacts groups.

Mujik answered 11/7, 2013 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.