I have begin to use Firebase but my experience is terrible.
I cannot sign out user.
I have tried different things and spend all my 4 days to figure out how to si
I also have this problem, right now, the LogoutBtn is inside a drawer, like this:
case R.id.initiates_logout:
if(FirebaseAuth.getInstance().getCurrentUser()!=null){
new AlertDialog.Builder(this)
.setTitle("Text1")
.setMessage("Text2")
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
FirebaseAuth.getInstance().signOut();
LoginManager.getInstance().logOut();
}})
.setNegativeButton(android.R.string.no, null).show();
}
break;
And i cant select another account after the logout.
If you check the Firebase Auth Quickstart sample code, the sign-out for Google provider includes these steps.
Are you calling Auth.GoogleSignInApi.signOut()
when you sign-out? So, please use this code:
private void signOut() {
// Firebase sign out
mAuth.signOut();
// Google sign out
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
//do what you want
}
});
}
You are using a newer version than me, I doubt they introduced a new bug. You mentioned NullPointerException
earlier, so I suggest you make sure the GoogleApiClient you pass to Auth.GoogleSignInApi.getSignInIntent
is not null.