我创建了一个同步适配器与虚拟帐户设置,我不希望它出现在设置应用程序的帐户列表中,也不当用户按下设置添加帐户按钮。我在我的同步适配器定义中尝试过android:userVisible =“false”,但仍出现该帐户。我已经在模拟器和3个物理设备上试过了。一切正常工作,它同步所有我需要的数据,唯一错误的是,我看到列表上的帐户,我不想。隐藏同步适配器虚拟帐户从
我authenticator.xml是:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="net.astagor.android.hhp.account"
android:icon="@drawable/ic_launcher"
android:smallIcon="@drawable/ic_launcher"
android:label="@string/app_name"
/>
我syncadapter.xml是:
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="net.astagor.android.hhp"
android:accountType="net.astagor.android.hhp.account"
android:userVisible="false"
android:supportsUploading="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"
/>
我加我adpater这样的:
Account account = AuthenticatorService.GetAccount();
AccountManager accountManager = (AccountManager) context
.getSystemService(Context.ACCOUNT_SERVICE);
if (accountManager.addAccountExplicitly(account, null, null)) {
ContentResolver.setIsSyncable(account, StubProvider.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account,
StubProvider.AUTHORITY, true);
ContentResolver.addPeriodicSync(account, StubProvider.AUTHORITY,
new Bundle(), SYNC_FREQUENCY);
}
而我得到的帐户列表和添加帐户列表中的帐户。
请帮忙! :)
我对这个问题的答案很感兴趣(如果有更好的方法) –
同样的问题在这里。从文档中获取所有内容,就像你一样 - 不要让虚拟帐户可见,但它总是显示! :-(这里有什么坏的? – Zordid