用户没有登出firebase android

时间:2018-02-13 18:58:14

标签: java android firebase firebase-authentication

用户未登出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},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:将调度发送到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:通知id令牌监听器有关签出事件的信息。   02-13 23:54:19.706 3073-3073 / com.example.imran.blooddonors D / FirebaseAuth:通知身份验证状态监听器有关退出事件。

1 个答案:

答案 0 :(得分:1)

在此方法中:

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");
     }