title: Firebase USer Registration - Screens won't go away
body: <p>I'm trying to implement Firebase Authentication into my App, and when an existing user installs the latest version the authentication screen won't disappear no matter how many times they sign in.</p>
  
  <p>Its really odd - was working perfectly until I moved to a new computer.</p>
  
  <p>It doesn't seem to apply to new accounts, but existing accounts that were previously set up can't login to the new version of the app.</p>
  
  <pre><code>mAuthStateListener = new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              FirebaseUser user = firebaseAuth.getCurrentUser();
              if (user != null) {
                  //user is signed in
                  onSignedInInialise(user.getDisplayName());
  
              } else {
                  //user is signed out
                  onSignedOutCleanup();
                  startActivityForResult(
                          AuthUI.getInstance()
                                  .createSignInIntentBuilder()
                                  .setIsSmartLockEnabled(false)
                                  .setProviders(Arrays.asList(
                                          new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                          new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()))
                                  .build(),
                          RC_SIGN_IN);
              }
  
          }
      };
  
  
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == RC_SIGN_IN) {
          if (resultCode == RESULT_OK) {
              FirebaseUser user = mFirebaseAuth.getCurrentUser();
              String uid = user.getUid();
              String userName = user.getDisplayName();
              String userEmail = user.getEmail();
              Uri userProfilePic = user.getPhotoUrl();
              createUserInFirebaseHelper(uid, userName, userEmail);
              Toast.makeText(MainActivity.this, "Hello " + userName + "!", Toast.LENGTH_SHORT).show();
  
          } else if (resultCode == RESULT_CANCELED) {
              Toast.makeText(MainActivity.this, "Sign in cancelled", Toast.LENGTH_SHORT).show();
              finish();
          }
      } else if (requestCode == GPS_PERMISSION) {
  
          String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
          if (provider != null) {
              getLocation();
          } else {
              Toast.makeText(this, "You must enable Gps to get your location", Toast.LENGTH_SHORT).show();
          }
      }
  }
  
  
  @Override
  protected void onResume() {
      super.onResume();
      mFirebaseAuth.addAuthStateListener(mAuthStateListener);
  }
  
  
  
      @Override
  protected void onPause() {
      super.onPause();
      if (mAuthStateListener != null) {
          mFirebaseAuth.removeAuthStateListener(mAuthStateListener);
      }
      detachDatabaseReadListener();
  }
  </code></pre>