title: Displaying SplashScreen while user waits authentication from FirebaseAuth
body: <p>I'm trying to display a splash screen on my App and I've managed to do it using a Handler and a Runnable object that constructs an intent and after 2 seconds changes activities to my login activity using the intent constructed</p>
  
  <p>However, now I've set up the Firebase Authentication. I've tried to construct the intent to match the expected behavior:<br>
  (user signedIn --> show SplashScreen --> Skip LoginActivity)<br>
  (user notSignedIn --> show SplashScreen --> Show LoginActivity)<br>
  Here's the code I'm currently working on: </p>
  
  <pre><code>public class SplashScreenActivity extends AppCompatActivity {
  
  
      private FirebaseAuth mAuth = null;
      private FirebaseAuth.AuthStateListener mAuthListener;
  
      /** Duration of wait **/
      private final int SPLASH_DISPLAY_LENGTH = 1000;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.activity_splash_screen);
  
          new Handler().postDelayed(new Runnable(){
              @Override
              public void run() {
                  mAuth = FirebaseAuth.getInstance();
                  mAuthListener = new FirebaseAuth.AuthStateListener() {
                      @Override
                      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
  
                          FirebaseUser user = firebaseAuth.getCurrentUser();
                          if (user != null) {
                              // User is signed in, send to mainmenu
                              Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
                              startActivity(new Intent(SplashScreenActivity.this, MainMenuActivity.class));
                          } else {
                              // User is signed out, send to register/login
                              startActivity(new Intent(SplashScreenActivity.this, MainActivity.class));
                          }
                      }
                  };
              }
          }, SPLASH_DISPLAY_LENGTH);
  
      }
  }
  </code></pre>
  
  <p>I've ommited the imports to shorten the code. The problem is that the app stay indefinetely in the splashscreen.</p>