title: Firebase: How to keep an Android user logged in?
body: <p>I'm using Firebase SimpleLogin to enable Email / Password authentication. Creation of users and subsequent login is all working fine. However, whenever I leave the app (even if only for a few seconds) the user is never logged in on my return i.e...</p>
  
  <pre><code>authClient.checkAuthStatus(new SimpleLoginAuthenticatedHandler())...
  </code></pre>
  
  <p>Always returns a null user.</p>
  
  <p>I am not logging out the user via the API. Also I have set the number of days the user is logged in to 21 in the Firebase console.</p>
  
  <p>I have seen mention of a remember-me param in the JS docs, but I can't see any equivalent for Android / Java.</p>
  
  <p>Wondering if I'm missing anything in the docs or if it's not possible for Android?</p>
  
  <p>Thanks for your help,</p>
  
  <p>Neil.</p>
  
  <p>Edit: Added code sample.</p>
  
  <p>User creation....</p>
  
  <pre><code>public void registerUserForChat(final MyApplication application, String email, String password) {
      Firebase ref = new Firebase(FIREBASE_URL);
      SimpleLogin authClient = new SimpleLogin(ref);
      authClient.createUser(email, password, new SimpleLoginAuthenticatedHandler() {
          @Override
          public void authenticated(com.firebase.simplelogin.enums.Error error, User user) {
              if(error != null) {
                  Log.e(TAG, "Error attempting to create new Firebase User: " + error);
              }
              else {
                  Log.d(TAG, "User successfully registered for Firebase");
                  application.setLoggedIntoChat(true);
              }
          }
      });
  }
  </code></pre>
  
  <p>User login....</p>
  
  <pre><code>public void loginUserForChat(final MyApplication application,  String email, String password) {
      Log.d(TAG, "Attempting to login Firebase user...");
      Firebase ref = new Firebase(FirebaseService.FIREBASE_URL);
      final SimpleLogin authClient = new SimpleLogin(ref);
      authClient.checkAuthStatus(new SimpleLoginAuthenticatedHandler() {
          @Override
          public void authenticated(com.firebase.simplelogin.enums.Error error, User user) {
              if (error != null) {
                  Log.d(TAG, "error performing check: " + error);
              } else if (user == null) {
                  Log.d(TAG, "no user logged in. Will login...");
                  authClient.loginWithEmail(email, password, new SimpleLoginAuthenticatedHandler() {
                      @Override
                      public void authenticated(com.firebase.simplelogin.enums.Error error, User user) {
                          if(error != null) {
                              if(com.firebase.simplelogin.enums.Error.UserDoesNotExist == error) {
                                  Log.e(TAG, "UserDoesNotExist!");
                              } else {
                                  Log.e(TAG, "Error attempting to login Firebase User: " + error);
                              }
                          }
                          else {
                              Log.d(TAG, "User successfully logged into Firebase");
                              application.setLoggedIntoChat(true);
                          }
                      }
                  });
              } else {
                  Log.d(TAG, "user is logged in");
              }
          }
      });
  }
  </code></pre>
  
  <p>So loginUserForChat method first checks to see if there is a logged in user and, if not, performs the login. Note that every time I start the app, the logging I see is....</p>
  
  <ol>
  <li>Attempting to login Firebase user...</li>
  <li>no user logged in. Will login...</li>
  <li>User successfully logged into Firebase</li>
  </ol>
  
  <p>If I exit the app, even for a few seconds, and return - I see the same logging.</p>
  
  <p>One thing I noticed is that the call to <em>checkAuthStatus</em> does not take any user credentials - I assume it just checks for <em>any</em> locally logged in user?</p>
  
  <p>Much appreciated.</p>