java FirebaseAuth。getInstance()。signOut()不会注销
我试图从firebase注销用户,但在我关闭应用程序并再次打开后,该用户仍然处于连接状态
我尝试了firebase用户的常规注销,但没有解决问题。 我想知道是什么导致了这个问题
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseAuth.getInstance().signOut();
Intent picture_intent = new Intent(Dashboard.this,LoginActivity.class);
startActivity(picture_intent );
}
});
我的检查用户是否连接:
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser currentUser = firebaseAuth.getCurrentUser();
if(currentUser != null)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
int again = preferences.getInt(String.valueOf(R.string.remember_me), 0);
if(again == 0)
{
Intent i = new Intent(getApplicationContext(), PagerActivity.class);
startActivity(i);
}
else
{
Intent i = new Intent(getApplicationContext(), Dashboard.class);
startActivity(i);
}
}
}
# 1 楼答案
为什么要使用SharedReference?如果您正在使用firebase维护会话,则不需要SharedReference。 顺便说一句,你的代码似乎是正确的。在调用注销函数后,尝试执行以下修改
并完全删除你的onAuthStateChanged()方法(因为我看不到你的完整代码,可能是你弄乱了这个方法内部的东西),所以,为了测试,删除这个方法,并按照我说的那样,将标志添加到你的意图中
如果有效,请告诉我
希望这对你有帮助。谢谢
# 2 楼答案
我认为您的注销是正确的,但是当您移动到
在可能再次登录用户的地方,必须对登录活动进行某些更改