隐藏虚拟帐户同步适配器的设置 [英] Hide dummy Account for Sync Adapter from Settings

查看:167
本文介绍了隐藏虚拟帐户同步适配器的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个同步适配器与虚拟帐户,我不希望它出现在设置应用程序的帐户就行了,也不当用户presses在设置中添加帐户按钮。我曾尝试机器人:在我的同步适配器定义userVisible =假,但仍是帐户出现。我已经在模拟器和3个物理设备尝试这样做。一切正常,它同步所有我需要的数据而言,唯一错的是我看到名单上的帐户,我不想。

I have created a Sync Adapter with a dummy Account and I don't want it to appear on the Account list in the Settings application, nor when a user presses the add account button in Settings. I have tried android:userVisible="false" in my sync-adapter definition, but still the account appears. I've tried this on an emulator and 3 physical devices. Everything works correctly in terms that it syncs all the data I need, the only thing wrong is that I see the Account on the list, and I don't want to.

我的authenticator.xml是:

My authenticator.xml is:

<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是:

My syncadapter.xml is:

<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是这样的:

And I add my adpater like this:

 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);
 }

而我得到的帐户列表和添加帐户列表中的帐户。

And the I get the account on the account list and in the add account list.

请帮助! :)

推荐答案

这是不是一个真正的答案,但如果你从authenticator.xml除去标签,它不添加帐户列表中显示,但图标那里点击添加帐户后无标签在列表中。丑陋的,可能不是一个好主意。 (此方法不隐藏至少在我的关系4运行4.4帐户 - 没有检查其他设备还)

This isn't a real answer, but if you remove the label from the authenticator.xml , it does not show in the list of added accounts , but the icon is there with no label in the list after clicking add account. Ugly and probably not a good idea. (this method does hide account at least on my nexus 4 running 4.4 - haven't checked other devices yet).

我相信用户可见的标志同步适配器只影响同步部分的显示选择帐户,在那里你可以看到最后同步时间后,设置自动同步设置,并触发同步。

I believe the user visible flag in sync adapter only affects the display of the sync part after selecting an account, where you can see the last sync time, set auto sync settings, and trigger sync.

我很想知道这也。它必须是可能的,因为我看不到我的帐户列表充斥着假帐户。因此,无论有一种方法或几乎没有的你已安装的应用程序的困扰与同步适配器?

I'd love to know this also. It must be possible, as I don't see my accounts list littered with dummy accounts. So either there's a way or almost none of my installed apps are bothering with sync adapters?

这篇关于隐藏虚拟帐户同步适配器的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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