4

我按照 android 提供的 SimpleSyncAdapter 示例创建了一个自定义帐户类型。我可以使用客户经理添加帐户,并且在某些手机上(在 Galaxy S3、Galaxy Nexus、HTC Desire HD 上测试),我确实在“设置”中的“帐户和同步”下看到了我的帐户。要添加帐户,我正在执行以下操作:

boolean added = mAccountManager.addAccountExplicitly(account, password, null);

但是,在 Galaxy Note 2 和 Motorola Xoom 上,即使返回 true,该帐户也不会出现在 Accounts and Sync 下。

有没有人见过这个问题?

4

2 回答 2

1

我错过了 setAccountAuthenticatorResult 调用。

boolean added = mAccountManager.addAccountExplicitly(account, password, new Bundle());
final Intent intent = new Intent();
intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, username);
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
setAccountAuthenticatorResult(intent.getExtras());
setResult(RESULT_OK, intent);
finish();
于 2014-04-04T01:24:37.827 回答
0

我遇到了这个问题,因为我在模拟器上遇到了同样的问题。我可以通过 AccountManager 访问帐户详细信息,但它没有显示在 Accounts & Sync 中。我终于在选中“擦除用户数据”的情况下重新启动了模拟器,问题就消失了。

我不知道如何在您的设备上模拟该过程,但也许使用 AccountManager.removeAccount(...) 删除所述帐户将清除一些旧帐户数据并允许您重置帐户。Account 数据、AccountManager 和 SyncAdapter 配置以及 Accounts & Sync 中的 Account 可用性之间显然存在脱节。我只是不明白它在哪里。

我希望这有助于知识渊博的贡献者更完整地回答原始问题。

于 2013-04-22T18:10:11.730 回答