Reputation: 67
User is not getting sign out Firebase android. When i press logout button it does not sign out.
Code is here:-
btnLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
logOut();
}
});
private void logOut() {
FirebaseAuth.getInstance().signOut();
}
Logs are:
02-13 23:54:19.654 3073-3073/com.example.imran.blooddonors I/View: Touch down dispatch to android.widget.Button{42d3afa0 VFED..C. ........ 120,594-600,690 #7f08002b app:id/btnAdminPanelLogout}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=218.52982, y[0]=88.352844, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=202325584, downTime=202325584, deviceId=2, source=0x1002 } 02-13 23:54:19.704 3073-3073/com.example.imran.blooddonors I/View: Touch up dispatch to android.widget.Button{42d3afa0 VFED..C. ...P.... 120,594-600,690 #7f08002b app:id/btnAdminPanelLogout}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=219.69275, y[0]=90.68005, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=202325635, downTime=202325584, deviceId=2, source=0x1002 } 02-13 23:54:19.706 3073-3073/com.example.imran.blooddonors D/FirebaseAuth: Notifying id token listeners about a sign-out event. 02-13 23:54:19.706 3073-3073/com.example.imran.blooddonors D/FirebaseAuth: Notifying auth state listeners about a sign-out event.
Upvotes: 1
Views: 8088
Reputation: 51
{
FirebaseAuth.instance.signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: ((context) => MainPage())));
},
Upvotes: 0
Reputation: 80934
Inside this method:
private void logOut() {
FirebaseAuth.getInstance().signOut();
Intent i=new Intent(getApplicationContext(),LoginActivity.class);
startActivity(i);
}
In the above the user will be signed out and then he will go to the LoginActivity.
Then inside your LoginActivity, you can check if there is a user logged in or no try this:
FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
if(user!=null){
Log.i("a user is logged in: ",user);
}
else{
Log.i("Username", "there is no user");
}
Upvotes: 4