title: How do I keep a user logged in after they logged in at least once?
body: <p>How do I keep user loged  in after they have signed in one time. I have a register activity that allows the the user to provide their email address and password, and once the user clicks submit an email confirmation is sent and then takes the user to the Login Activity. However once the user gets to the Login Activity they are automatically signed in. I would first like for them to validate their email first and then be signed in and stayed signed in unless they log out. I found some answers on stack-overflow about how to keep the user signed in and how to check if they validated their email but the code that I have skips the validation step and just signs the user in once taken to the login activity. </p>
  
  <pre><code>**Check to see if user enters correct credetials **
      public void loginUser(View view) {
          if (userEmailEditText.getText().toString().trim().equals("") || userPasswordEditText.getText().toString().trim().equals("")) {
              Toast.makeText(LoginActivity.this, "Enter the required information!", Toast.LENGTH_SHORT).show();
  
          } else {
              mAuth.signInWithEmailAndPassword(userEmailEditText.getText().toString(), userPasswordEditText.getText().toString())
                      .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                              if (task.isSuccessful()) {
                                  checkUserStatus();
                              } else {
                                  Toast.makeText(LoginActivity.this, "incorrect info", Toast.LENGTH_SHORT).show();
                              }
  
                          }
                      });
  
  
          }
  
  
      }
  
  **Keeps the user singed in i called this method in onCreate**
   public void keepUserSignedIn() {
          if (mAuth.getCurrentUser() != null) {
              startActivity(new Intent(LoginActivity.this, MainActivity.class));
              finish();
          }
  
      }
  
  
             private void createUser() {
  
                      mAuth.createUserWithEmailAndPassword(user.getUserEmail(), user.getUserPassword())
                              .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                                  @Override
                                  public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                                      if (task.isSuccessful()) {
                                          // Sign in success, update UI with the signed-in user's information
                                          //save user info if registration was successful
                                          saveUserInfo();
                                          sendVerificationEmail();
                                          progressDialog.dismiss();
                                      } else {
                                          progressDialog.dismiss();
                                          Log.i("error", task.getResult().toString());
                                          // If sign in fails, display a message to the user.
                                          Toast.makeText(RegisterActivity.this, "Error occurred", Toast.LENGTH_SHORT).show();
                                      }
                                  }
                              });
                  }
  
  
  
            public void sendVerificationEmail() {
                  FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
  
                  if (user != null) {
                      user.sendEmailVerification()
                              .addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                                  @Override
                                  public void onComplete(@NonNull Task&lt;Void&gt; task) {
                                      if (task.isSuccessful()) {
                                          Toast.makeText(RegisterActivity.this, "Verify your email...", Toast.LENGTH_SHORT).show();
           mAuth.signOut();
                  startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
  
                                      }
                                  }
                              });
                  }
  
              }
  
  
  
       //upload user's credetinals to firebase...
          public void saveUserInfo() {
              final ProgressDialog progressDialog = new ProgressDialog(this);
              progressDialog.setTitle("Uploading...");
              //rogressDialog.show();
              final String userId = mAuth.getCurrentUser().getUid();
              final StorageReference storageRef = FirebaseStorage.getInstance().getReference().child("ProfileImages").child(userId);
              storageRef.putFile(selectedImageUri).addOnCompleteListener(new OnCompleteListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
                      if (task.isSuccessful()) {
                          storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener&lt;Uri&gt;() {
                              @Override
                              public void onSuccess(Uri uri) {
                                  deviceToken = FirebaseInstanceId.getInstance().getToken();
                                  url = uri.toString();
                                  userDictionary.put("devicetoken", deviceToken);
                                  userDictionary.put("name", user.getUserName().trim());
                                  userDictionary.put("email", user.getUserEmail().trim());
                                  userDictionary.put("lastName", user.getLastName().trim());
                                  userDictionary.put("profileimage", url);
                                  userDictionary.put("user", userId);
                                  mDatabase.child(userId).setValue(userDictionary);
                                  progressDialog.dismiss();
                              }
                              //handles error
                          }).addOnFailureListener(new OnFailureListener() {
                              @Override
                              public void onFailure(@NonNull Exception e) {
                                  progressDialog.dismiss();
                                  Toast.makeText(RegisterActivity.this, "Error" + e.getMessage(), Toast.LENGTH_SHORT).show();
  
                              }
                          });
  
                      }
                  }
              });
          }
  </code></pre>