独自の Authenticator を作成し、それを 2 つの異なるアプリ (A と B) のライブラリとして使用しようとしています。 android-authenticator/ . アプリ A をインストールしてからアプリ B をインストールしました。アプリ A が AccountManager.addAccount() を呼び出すと、AccountAuthenticatorActivity が開きます。アプリ B が AccountManager.addAccount() を呼び出すと、何も起こりません。アプリ A をアンインストールしてアプリ B で再試行すると、AccountAuthenticatorActivity が開きます。
私の目標は、2 つのアプリに同じ AccountAuthenticatorActivity と AccountAuthenticator を使用することですが、一度に 1 つのアプリでしか機能しないようです。
これは、AbstractAccountAuthenticator の addAccount です。
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
intent.putExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);
intent.putExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);
intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
final Bundle bundle = new Bundle();
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
return bundle;
}
これは、両方のアプリから accountManager.addAccount() を呼び出す方法です。
private void addNewAccount(String accountType, String authTokenType) {
final AccountManagerFuture<Bundle> future = mAccountManager.addAccount(accountType, authTokenType, null, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
Bundle bnd = future.getResult();
} catch (Exception e) {
e.printStackTrace();
}
}
}, null);
}