How to make a user sign out in Firebase?

前端 未结 13 1618
猫巷女王i
猫巷女王i 2020-12-15 04:22

I am making a simple authentication app in Android using Firebase authentication. Till now I am successful in signing the user in, however the issue is that the user remains

13条回答
  •  萌比男神i
    2020-12-15 05:07

    You can simply call this

    FirebaseAuth.getInstance().signOut();
    

    If you want to perform some action after sign out then use this one.

    public void onClick(View v) {
        if (v.getId() == R.id.sign_out) {
            AuthUI.getInstance()
                .signOut(this)
                .addOnCompleteListener(new OnCompleteListener() {
                    public void onComplete(@NonNull Task task) {
                        // user is now signed out
                        startActivity(new Intent(MyActivity.this, SignInActivity.class));
                        finish();
                    }
                });
            }
        }
    

提交回复
热议问题