问题
I'm doing a signout on my APP like this :
FirebaseAuth.getInstance().signOut();
The problem is that when I return to my Login Activity and I press again Sign in it does a re-login with the same account.
What I'd like to do is something like this :
Auth.GoogleSignInApi.signOut(mGoogleApliClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
statusTextView.setText("Signed out");
}
});
If I do this (it's a button from Login Activity) it lets me log in with different account, but if I do only the FirebaseAuth.getInstance().signOut();
it does sign out, but if I do Login it re-log with the old email, is there any way to do this without having to create the mGoogleApiClient
, etc..? I have to do this in differents Activities and I don't want to create it on each Activity, if I do it works I've tested it, but I think it's kinda dirty.
回答1:
I've faced the same issue and I solved it doing this
FirebaseAuth.getInstance().signOut();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
this.finishAffinity();
}
else{
ActivityCompat.finishAffinity(this);
}
startActivity(new Intent(mContext,LoginActivity.class));
From the documentation
finishAffinity()
Finish this activity as well as all activities immediately below it in the current task that have the same affinity.
来源:https://stackoverflow.com/questions/48138882/signout-firebase