Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to select different account on google login for android

I have implemented Google Signing for Android app. The user can successfully login from the Google Login Button.

This screen appears while selecting a Social Account : 1

So now the user has logged in successfully by selecting his/her account.

Now, user logs out and tries to sign in again by using Google Login Button.

At this time, he is not asked with the option to choose account , he is automatically logged in using the account he/she selected at the first time.

At the time of logout what should I do to clear the cache of selected account.

like image 963
Karan Sharma Avatar asked Feb 20 '17 06:02

Karan Sharma


People also ask

How do I switch between Google accounts on my Android phone?

On your Android phone or tablet, go to myaccount.google.com. In the top right, tap your profile photo or name. Sign out. Sign in with the account you want to use.

How do I choose which Google account to sign into?

Switch between accounts On your computer, sign in to Google. On the top right, select your profile image or initial. On the menu, select the account you'd like to use.

How do I toggle between Google accounts?

On a browser, like Chrome On your computer, sign in to Google Docs, Sheets, or Slides. In the top right, click your profile photo or email address. Click the account you want to use.

How do I sign into another Google account on my phone?

Step 1: Open the Gmail app on your Android device. You should already be signed in to your first account. Step 2: To add your other accounts, tap on the Profile Picture icon in the top-right corner. Step 3: Select Add Another Account.


2 Answers

In firebase documentation for android, they only refer to use this:

Firebase.auth.signOut()

However, next time the user logs in, the app will automatically select the previous email. To avoid this, you should use the follow code as well:

googleSignInClient.signOut()
like image 193
Pedro Varela Avatar answered Nov 11 '22 19:11

Pedro Varela


As you didn't provide any code or reference how you are logging in and logging out, it might be that you incorrectly sign out user from the app.

So here is what docs describe one should do on user logout: https://developers.google.com/identity/sign-in/android/disconnect

Sign out:

Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
            new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    // ...
                }
            });

Note: You must confirm that GoogleApiClient.onConnected has been called before signing out.

Also check status which comes in onResult - maybe there is some error, which might lead to the answer.

like image 27
krossovochkin Avatar answered Nov 11 '22 19:11

krossovochkin