安卓:启用导入帐户中的联系人编程 [英] Android: Enable imported account contacts programmatically

查看:221
本文介绍了安卓:启用导入帐户中的联系人编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地引入外部接触到新创建的帐户使用本教程。该帐户设置重新同步编程,然而,要能看到同步联系人, - 除非接触欺骗被发现 - 我需要做的 Contacts->菜单 - >显示选项 - >查找问责>检查所有联系人。我已经害怕愤怒的用户,使联系人同步,不能够看到任何这样的问题是:是否有可能对包括进口的帐户中的联系人编程设置显示选项?因此,当用户选择了帐户创建,他不需要做任何其他人看到导入的联系人?

I'm successfully importing external contacts into the newly created account using this tutorial. The account is setup to re-sync programmatically and yet, to be able to see the synced contact, - unless the contact dupe is found - I need to do Contacts->Menu->Display options->Find account->Check "All Contacts". I'm already dreading angry users enabling contact sync and not being able to see anything so the question is: is it possible to set display option for including imported account contacts programmatically? So when user opt for account creation he doesn't need to do anything else to see imported contacts?

推荐答案

我有同样的问题,并通过帐户创建解决了它与下面code:

i had the same problem and solved it with following code via account creation:

mAccountManager.addAccountExplicitly(account, mPassword, null);
// Set contacts sync for this account.
ContentResolver.setSyncAutomatically(account,
ContactsContract.AUTHORITY, true);
ContentProviderClient client = getContentResolver().acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
ContentValues cv = new ContentValues();
cv.put(Groups.ACCOUNT_NAME, account.name);
cv.put(Groups.ACCOUNT_TYPE, account.type);
cv.put(Settings.UNGROUPED_VISIBLE, true);
try {
client.insert(Settings.CONTENT_URI.buildUpon()                  .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
.build(), cv);
} catch (RemoteException e) {...}

这篇关于安卓:启用导入帐户中的联系人编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆