简体   繁体   English

用户没有退出 firebase android

[英]User is not getting sign out firebase android

User is not getting sign out Firebase android.用户没有退出 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. 02-13 23:54:19.654 3073-3073/com.example.imran.blooddonors I/View:着陆调度到 android.widget.Button{42d3afa0 VFED..Z0D61F8370CAD1D412F80B84D143E12 ........ 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. ........ 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: Notifying id token listeners about a sign-out event. ...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: Notifying auth state listeners about a sign-out event. 02-13 23:54:19.706 3073-3073/com.example.imran.blooddonors D/FirebaseAuth:通知 auth state 侦听器有关注销事件。

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. 在上面的用户将被注销,然后他将进入LoginActivity。

Then inside your LoginActivity, you can check if there is a user logged in or no try this: 然后在您的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");
     }
{ FirebaseAuth.instance.signOut(); Navigator.of(context).pushReplacement( MaterialPageRoute(builder: ((context) => MainPage()))); },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM