static final String EXTRA_HAS_MULTIPLE_USERS = "hasMultipleUsers";
private static final int CHOOSE_ACCOUNT_REQUEST = 1;
+ private static final int ADD_ACCOUNT_REQUEST = 2;
private PendingIntent mPendingIntent;
private AccountManagerCallback<Bundle> mCallback = new AccountManagerCallback<Bundle>() {
public void run(AccountManagerFuture<Bundle> future) {
+ boolean done = true;
try {
Bundle bundle = future.getResult();
- bundle.keySet();
- setResult(RESULT_OK);
-
- if (mPendingIntent != null) {
- mPendingIntent.cancel();
+ //bundle.keySet();
+ Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
+ if (intent != null) {
+ done = false;
+ Bundle addAccountOptions = new Bundle();
+ addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
+ addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS,
+ Utils.hasMultipleUsers(AddAccountSettings.this));
+ intent.putExtras(addAccountOptions);
+ startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
+ } else {
+ setResult(RESULT_OK);
+ if (mPendingIntent != null) {
+ mPendingIntent.cancel();
+ mPendingIntent = null;
+ }
}
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "account added: " + bundle);
} catch (AuthenticatorException e) {
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "addAccount failed: " + e);
} finally {
- finish();
+ if (done) {
+ finish();
+ }
}
}
};
// Go to account setup screen. finish() is called inside mCallback.
addAccount(data.getStringExtra(EXTRA_SELECTED_ACCOUNT));
break;
+ case ADD_ACCOUNT_REQUEST:
+ setResult(resultCode);
+ if (mPendingIntent != null) {
+ mPendingIntent.cancel();
+ mPendingIntent = null;
+ }
+ finish();
+ break;
}
}
null, /* authTokenType */
null, /* requiredFeatures */
addAccountOptions,
- this,
+ null,
mCallback,
null /* handler */);
mAddAccountCalled = true;