Aritra Roy Aritra Roy - 3 years ago 240
Android Question

Google Plus Sign In Account Selection Dialog Issue


I am using Google Plus OAuth in my app along with Firebase. When the user taps the sign in button, and account selection dialog appears and the user selects the particular account of choice and signs in.


Suppose the user has two accounts in that device, A and B. Initially, he selects account A to sign in and then uses the app and then decides to sign out. Now he clicks the sign in button again, but the account selection dialog doesn't appear and it automatically signs in using the previously selected account A.


I want the user to be presented with the account selection dialog every time and give them a chance to select a different account if they want to.


Here is a small code snippet of how I am using the Google Api Client for sign in.

String mClientId = parcel.getProviderExtra().getString(CLIENT_ID_KEY);
GoogleSignInOptions googleSignInOptions;

googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)

mGoogleApiClient = new GoogleApiClient.Builder(activity)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)


and sign out,


Any help will be highly appreciated.

Answer Source

Got this resolved by clearing the default account every time before sign in.

    public void startLogin(Activity activity, String mEmail) {
        Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
         * Clearing default account every time so that the account picker dialog can be enforced
        if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
        activity.startActivityForResult(signInIntent, RC_SIGN_IN);

This will enforce the dialog to appear every time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download