用户没有退出Firebase android。当我按登出按钮时,它不会退出。
代码在这里:
btnLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
logOut();
}
});
private void logOut() {
FirebaseAuth.getInstance().signOut();
}
日志是:
02-13 23:54:19.654 3073-3073 / com.example.imran.blooddonors I / View:着陆调度到android.widget.Button {42d3afa0 VFED..C。 ........ 120,594-600,690#7f08002b app:id / btnAdminPanelLogout},事件= MotionEvent {action = ACTION_DOWN,id [0] = 0,x [0] = 218.52982,y [0] = 88.352844,toolType [0] = TOOL_TYPE_FINGER,buttonState = 0,metaState = 0,标志= 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:修改调度到android.widget.Button {42d3afa0 VFED..C。 ... P .... 120,594-600,690#7f08002b app:id / btnAdminPanelLogout},事件= MotionEvent {action = ACTION_UP,id [0] = 0,x [0] = 219.69275,y [0] = 90.68005,toolType [0] = TOOL_TYPE_FINGER,buttonState = 0,metaState = 0,标志= 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:向ID令牌侦听器通知退出事件。
02-13 23:54:19.706 3073-3073 / com.example.imran.blooddonors D / FirebaseAuth:向认证状态侦听器通知退出事件。
最佳答案
在此方法内:
private void logOut() {
FirebaseAuth.getInstance().signOut();
Intent i=new Intent(getApplicationContext(),LoginActivity.class);
startActivity(i);
}
在上面的用户将被注销,然后他将进入LoginActivity。
然后在您的LoginActivity内部,可以检查是否有用户登录或不尝试此操作:
FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
if(user!=null){
Log.i("a user is logged in: ",user);
}
else{
Log.i("Username", "there is no user");
}