Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 218
Henry Pootle Avatar asked Dec 05 '10 20:12

Henry Pootle


1 Answers

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

like image 104
Henry Pootle Avatar answered Oct 16 '22 04:10

Henry Pootle