我試圖編寫自己的Authenticator並將它用作具有兩個不同應用程序的庫:A和B. 我已按照此帖發表:http://udinic.wordpress.com/2013/04/24/write-your-own-android-authenticator/。 我安裝了應用程序A,然後安裝了應用程序B.當應用程序A調用AccountManager.addAccount()時,AccountAuthenticatorActivity打開。當應用程序B調用AccountManager.addAccount()時沒有任何事情發生。如果我卸載應用程序A並在應用程序B中再次嘗試,則AccountAuthenticatorActivity將打開。無法讓我的AccountAuthenticatorActivity在兩個不同的應用程序中打開
我的目標是要使用的兩個應用程序相同的AccountAuthenticatorActivity和AccountAuthenticator,但它似乎在一個應用程序在同一時間只工作。
這是addAccount我AbstractAccountAuthenticator:
@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);
}
我錯過了 「出口=真」 在我的認證活動的價值。謝謝! – user1787773
很高興我能幫上忙 –