【发布时间】:2014-09-21 06:44:38
【问题描述】:
使用 SyncAdapter 框架,我的应用程序显示在设置菜单的添加帐户选项中:
当我选择“添加帐户”时,我可以在列表中看到我的应用,但选择它只会冻结设置。
我想我应该通过使用一些意图过滤器来告诉设置要在我的应用上运行什么活动,但我没有找到如何..
任何帮助都将在这里得到赞赏!
【问题讨论】:
标签: android settings account android-syncadapter
使用 SyncAdapter 框架,我的应用程序显示在设置菜单的添加帐户选项中:
当我选择“添加帐户”时,我可以在列表中看到我的应用,但选择它只会冻结设置。
我想我应该通过使用一些意图过滤器来告诉设置要在我的应用上运行什么活动,但我没有找到如何..
任何帮助都将在这里得到赞赏!
【问题讨论】:
标签: android settings account android-syncadapter
转到我们扩展 AbstractAccountAuthenticator 并覆盖 addAccount 方法的类。 如果 addAccount 方法没有被覆盖并且它是空的,那么问题将是相同的。
覆盖所示的方法。
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle bundle) throws NetworkErrorException {
final Bundle result = bundle;
Intent intent = new Intent(this.context, MainActivity.class);
intent.putExtra("authtokenType", authTokenType);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
result.putParcelable(AccountManager.KEY_INTENT, intent);
return result;
}
添加此代码后,去检查设置的添加帐户。
【讨论】: