This is my coding in my java class file where my log out button is located at. How do I log out of my Google Account in Firebase in android studio, such that when I log in again, I am allowed to choose the account I am able to sign in with. Right now, I am always being logged in with the same account.
private GoogleSignInClient mGoogleSignInClient; Button btnLogout; FirebaseAuth mAuth; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); btnLogout = findViewById(R.id.btnLogout); mAuth=FirebaseAuth.getInstance(); btnLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAuth.signOut(); mGoogleSignInClient.signOut(); Intent intent = new Intent(Profile.this, SplashPage.class); startActivity(intent); } }); } }
Advertisement
Answer
FirebaseAuth.getInstance().signOut()
does soft sign out and if you want to be able to choose Google user again on sign in do full google sign out GoogleSignIn.getClient(activity, googleSignInOptions).signOut()