SetupWizard: Use GMS AccountManager as intended
Change-Id: I1c2bac11745d0d6b9a9378e483d1b64b01f5df44
This commit is contained in:
parent
61a331f403
commit
b990a954a8
@ -80,44 +80,26 @@ public class GmsAccountPage extends SetupPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void launchGmsAccountSetup(final Activity activity) {
|
public void launchGmsAccountSetup(final Activity activity) {
|
||||||
/*
|
|
||||||
* XXX: The AccountIntro intent is now public and therefore likely to change.
|
|
||||||
* The only way to catch whether the user pressed skip of back if via
|
|
||||||
* startActivityForResult.
|
|
||||||
*
|
|
||||||
* If this fails, fall back to the old method, but it is not ideal because only a
|
|
||||||
* OperationCanceledException is thrown regardless of skipping or pressing back.
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
Intent intent = new Intent("com.google.android.accounts.AccountIntro");
|
|
||||||
intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
|
||||||
intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
|
|
||||||
intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
|
|
||||||
activity.startActivityForResult(intent, SetupWizardApp.REQUEST_CODE_SETUP_GMS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
||||||
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
|
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
|
||||||
bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
|
bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
|
||||||
AccountManager
|
AccountManager
|
||||||
.get(activity).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null,
|
.get(activity).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null,
|
||||||
bundle, activity, new AccountManagerCallback<Bundle>() {
|
bundle, null, new AccountManagerCallback<Bundle>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(AccountManagerFuture<Bundle> bundleAccountManagerFuture) {
|
public void run(AccountManagerFuture<Bundle> future) {
|
||||||
try {
|
try {
|
||||||
if (bundleAccountManagerFuture.getResult()
|
Bundle result = future.getResult();
|
||||||
.getString(AccountManager.KEY_AUTHTOKEN) != null) {
|
Intent intent = result
|
||||||
setCompleted(true);
|
.getParcelable(AccountManager.KEY_INTENT);
|
||||||
}
|
activity.startActivityForResult(intent,
|
||||||
|
SetupWizardApp.REQUEST_CODE_SETUP_GMS);
|
||||||
} catch (OperationCanceledException e) {
|
} catch (OperationCanceledException e) {
|
||||||
if (activity != null && activity.isResumed()) {
|
|
||||||
getCallbacks().onNextPage();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
} catch (AuthenticatorException e) {
|
} catch (AuthenticatorException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user