有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java用户无法注销firebase 安卓

用户无法注销Firebase 安卓。当我按下注销按钮时,它不会注销

代码如下:-

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: Touch down dispatch to 安卓.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 安卓.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.


共 (1) 个答案

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