Skip to content

Instantly share code, notes, and snippets.

@stupidly-logical
Created September 6, 2019 14:43
Show Gist options
  • Save stupidly-logical/df6793bd87cb5019556432291e3a3fcc to your computer and use it in GitHub Desktop.
Save stupidly-logical/df6793bd87cb5019556432291e3a3fcc to your computer and use it in GitHub Desktop.
Safely signing out using FirebaseAuth in Android
//Declaration and defination
private FirebaseAuth firebaseAuth;
FirebaseAuth.AuthStateListener authStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if (firebaseAuth.getCurrentUser() == null){
//Do anything here which needs to be done after signout is complete
signOutComplete();
}
else {
}
}
};
//Init and attach
firebaseAuth = FirebaseAuth.getInstance();
firebaseAuth.addAuthStateListener(authStateListener);
//Call signOut()
firebaseAuth.signOut();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment