开发者

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

开发者 https://www.devze.com 2023-01-28 19:21 出处:网络
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 Acco

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 exam开发者_JAVA百科ple on Desire and couldn't see them in this list too. Does anyone know any solution?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消