Erik Hellberg Erik Hellberg - 2 months ago 19
Android Question

Why is my FirebaseAuth instance still have the user in FirebaseAuth.getCurrentUser()?

I go through this Build an Android App Using Firebase tutorial and I'm confused about why the

FirebaseAuth.getCurrentUser()
keeps returning the user even if I run this code:

private void signOut() {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Toast.makeText(Application.getInstance(), status.getStatus().toString(), Toast.LENGTH_SHORT).show();
mainAdapterOnChange();
}
});
}

private void revokeAccess() {
Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Toast.makeText(Application.getInstance(), "revokeAccess: status = " + status, Toast.LENGTH_SHORT).show();
}
});
}


I think pressing the Google sign-in button to authenticate the user is working, because after I
GoogleSignInApi.signOut
and press the button again, I can select the Gmail account to log in with.

But why is my
FirebaseAuth
instance still have the user in
FirebaseAuth.getCurrentUser()
?

Answer

you need to signout of the firebase instance also then only current user will be removed. Try this code

 FirebaseAuth.getInstance().signOut();

U can try out this latest link

Comments