title: Android Studio (Kotlin) - User has to log back into app every time app is closed
body: <p>So i have a <code>RegisterActivity</code> and a <code>MapsActivity</code>.
  When a new user opens the app, they will be on the <code>RegisterActivity</code> and sign up. Once they sign up, my app creates an <code>Intent</code> and sends them to the <code>MapsActivity</code></p>
  
  <p>The problem is whenever the user closes the app, they have to login/register again.</p>
  
  <p>I want the the app to be able to open back to the <code>MapsActivity</code> since the user has not signed out yet</p>
  
  <hr>
  
  <p>Here's my attempt:</p>
  
  <p>i put an <code>&lt;intent-filter&gt;</code> in both <code>RegisterActivity</code> and <code>MapsActivity</code> because i think both should both be the main launchers depending if a user is logged in or not right?</p>
  
  <ul>
  <li>If they aren't logged in, then the main launcher should be <code>RegisterActivity</code></li>
  <li>If they are logged in, then the main launcher should be <code>MapsActivity</code> </li>
  </ul>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;application
      &lt;activity android:name=".MapsActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN"/&gt;
              &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".RegisterActivity"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN"/&gt;
          &lt;action android:name="android.intent.action.VIEW"/&gt;
          &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
      &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".LoginActivity"&gt;
      &lt;/activity&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p><strong>MapsActivity.kt</strong></p>
  
  <pre><code>public override fun onStart() {
      super.onStart()
      // Check if user is signed in (non-null) and update UI accordingly.
      val currentUser = FirebaseAuth.getInstance().currentUser
      if(currentUser == null){
          Log.d(TAG, "User is not logged in")
          val intent = Intent(this, LoginActivity::class.java)
          intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK.or(Intent.FLAG_ACTIVITY_NEW_TASK)
          startActivity(intent)
      }else {
          Log.d(TAG, "User is logged in")
      }
  }
  </code></pre>