.getCurrentUser() does not return non-null when I restart the app, therefore I stay stuck in MainActivity rather than being transferred to LogIn.class. Meaning that I am accordingly to firebase loged in constantly
I've tried attaching AuthStateListener, which does not seem to fix the problem.
@Override
protected void onStart() {
super.onStart();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if(user == null){
Intent intent = new Intent(MainActivity.this, LogIn.class);
startActivity(intent);
finish();
} else{
}
}
Users stay signed in until you call signOut() . So if you want getCurrentUser to return null, you must call that ahead of time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.