GrafOrlov GrafOrlov - 4 months ago 92
Android Question

Google Firebase sign out and forget user in Android app

I have faced with the next problem:

when I call

mFirebaseAuth.signOut();
or
mFirebaseUser.delete();
my
FirebaseAuth.AuthStateListener()
works correct and returns
null
as
FirebaseUser
instance in
onAuthStateChanged
, i refresh UI and show "Sign in with Google" button.

But when I want to log in again, I don't see the pop-up with users (i have 2 users on my device, attached the image). The app shows this pop-up only in first sign in, after that it uses the same user. If i clear app's data on the settings screen I will be able to see this pop-up again.

My question is how to show this pop-up after every sign out.

enter image description here

UPDATE:
I run this code when press Sign In button:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, FirebaseActivity.REQUEST_SIGN_IN);


in
onActivityResult()
i gen an instance of
GoogleSignInResult
so everything i need happens after i call
startActivityForResult()

Answer

In the Firebase Auth Quickstart sample code, the sign-out for Google provider includes these steps. Are you calling Auth.GoogleSignInApi.signOut() when you sign-out?

private void signOut() {
    // Firebase sign out
    mAuth.signOut();

    // Google sign out
    Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
            new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    updateUI(null);
                }
            });
}