How do I logout out of Google Sign In?
I know that I would be able to call mGoogleSignInClient.signOut()
, but I create the mGoogleSignInClient in my login activity. How could I access it in my settings activity (where the logout happens)?
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("id_token")
.requestEmail()
.build()
googleSignInClient = GoogleSignIn.getClient(this, gso)
In my settings activity, where I have the logout button, I want to be able to call some static method relating to the Google Sign-In SDK and logout.
Do I really need to repeat the steps above (which I implemented in my login activity) into my settings activity (where the logout button is)?
You can use this for logout click
Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
//set your action after log out
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With