I have DispatchActivity as my Launcher activity, which is designed to check if there is a user who is currently logged in. If the user is registered, I submit it to my ProfileActivity. Otherwise, I submit them to LogInActivity. Here is my code in DispatchActivity:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dispatch); //..................... auth = FirebaseAuth.getInstance(); authListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { launchProfileActivity(); } else { // User is signed out launchLoginActivity(); } } }; } @Override public void onStart() { super.onStart(); auth.addAuthStateListener(authListener); } @Override public void onStop() { super.onStop(); if (authListener != null) { auth.removeAuthStateListener(authListener); } }
No matter what I do, firebaseAuth.getCurrentUser () never returns null on my main test device. According to Docs, getCurrentUser () will be null unless the user is logged in. When I register some data of this user, they are consistent with the user "Test" that I created earlier (for example, calling user.getEmail () returns " email@example.com ".
This is problematic, since I certainly do not have users in my console user database (In Authentication / Users). I removed this User test from the database a while ago, and the database is empty .
I tried to run the application on another device and executed it correctly. However, when I perform a new installation on my primary test device, it does not complete the problem.
Question: As far as I can see, the problem is related to some constant state of the user with my device; since another device is working, itβs working fine. Since I did not intentionally configure this, I would like to know what causes this inconsistency between my Auth User Database and Device.
If the database is empty, where does auth.getCurrentUser () get this previously deleted user object from?
Thanks.
source share