title: When I start the app first time, the username is null
body: <pre><code>public class SplashActivity extends AppCompatActivity {
  
      private final int SPLASH_DISPLAY_LENGTH = 1000;
      private FirebaseAuth mAuth;
      private FirebaseFirestore db;
      private static String userName;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          generateUserName();
  
          try {
              sleep(500);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          mAuth = FirebaseAuth.getInstance();
          FirebaseUser user = mAuth.getCurrentUser();
  
          if(user!=null){
              Intent intent = new Intent(SplashActivity.this, MainActivity.class);
              Toast.makeText(this, userName, Toast.LENGTH_SHORT).show();
              intent.putExtra("name", userName);
              startActivity(intent);
              finish();
          }else{
              setContentView(R.layout.activity_splash);
              new Handler().postDelayed(new Runnable() {
                  @Override
                  public void run() {
                      Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                      startActivity(intent);
                      finish();
                  }
              }, SPLASH_DISPLAY_LENGTH);
          }
      }
  
      private void generateUserName(){
          FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
          db = FirebaseFirestore.getInstance();
          db.collection("users").document(user.getEmail())
                  .get()
                  .addOnCompleteListener(new OnCompleteListener&lt;DocumentSnapshot&gt;() {
              @Override
              public void onComplete(@NonNull Task&lt;DocumentSnapshot&gt; task) {
                  userName = task.getResult().get("name").toString();
              }
          });
      }
  
  }
  </code></pre>
  
  <p>This Activity is SplashActivity. So the app will skip this activity when the user is logged in already. but weird thing is happening in this code.
  the variable <code>userName</code> get the name data of user in FireStore.
  but when I start the app first time, It's null.
  but then after pushing the backButton on my phone, the app shows MainActivity and the name is not null.
  it's very weird. and I don't understand why it's like this.</p>
  
  <p>I don't know how to solve this problem.</p>