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

梦想与她 提交于 2019-12-03 13:20:24
Henry Pootle

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!