title: Navigation causes crash after opening killed activity
body: <p>My app crashes after restarting killed activity that uses multiple back stack as shown in <a href="https://github.com/android/architecture-components-samples/blob/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample/NavigationExtensions.kt" rel="nofollow noreferrer">samples</a> for bottom navigation tabs. It only crashes when using multistack.</p>
  <p>Stacktrace:</p>
  <pre><code> Caused by: java.lang.IllegalArgumentException
      at androidx.lifecycle.LifecycleRegistry.downEvent(LifecycleRegistry.java:263)
      at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:314)
      at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334)
      at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
      at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.java:118)
      at androidx.navigation.NavBackStackEntry.updateState(NavBackStackEntry.java:150)
      at androidx.navigation.NavBackStackEntry.setMaxLifecycle(NavBackStackEntry.java:130)
      at androidx.navigation.NavController.popBackStackInternal(NavController.java:325)
      at androidx.navigation.NavController.dispatchOnDestinationChanged(NavController.java:426)
      at androidx.navigation.NavController.onGraphCreated(NavController.java:636)
      at androidx.navigation.NavController.setGraph(NavController.java:586)
      at androidx.navigation.NavController.setGraph(NavController.java:551)
      at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:247)
      at androidx.fragment.app.Fragment.performCreate(Fragment.java:2867)
      at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:444)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1287)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1444)
      at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1522)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1575)
      at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3001)
      at androidx.fragment.app.FragmentManager.dispatchCreate(FragmentManager.java:2938)
      at androidx.fragment.app.FragmentController.dispatchCreate(FragmentController.java:240)
      at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:243)
      at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:118)
      at my.base.ui.base.DaggerActivity.onCreate(DaggerActivity.kt:26)
      at my.base.ui.base.delegate.LocalizationActivity.onCreate(LocalizationActivity.kt:29)
      at my.base.ui.base.BaseActivity.onCreate(BaseActivity.kt:34)
      at my.base.ui.base.BaseFragNavActivity.onCreate(BaseFragNavActivity.kt:37)
      at my.app.ui.MainActivity.onCreate(MainActivity.kt:40)
      at android.app.Activity.performCreate(Activity.java:5937)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
      ... 10 more
  </code></pre>
  <p>Line where it throws the exception:</p>
  <pre><code>private static Event downEvent(State state) {
          switch (state) {
              case INITIALIZED:
                  throw new IllegalArgumentException();
  </code></pre>
  <p>Dependencies:</p>
  <pre><code>const val navigationFragment = &quot;androidx.navigation:navigation-fragment-ktx:2.3.0&quot;
  const val navigationUi = &quot;androidx.navigation:navigation-ui-ktx:2.3.0&quot;
  </code></pre>
  <p>Setup code:</p>
  <pre><code>binding.bottomNavigation.setupWithNavController(
              listOf(
                  R.navigation.nav1,
                  R.navigation.nav2,
                  R.navigation.nav3
              ),
              supportFragmentManager,
              R.id.container,
              intent
          ).observe(this) { controller -&gt;
              navController = controller
              controller.addOnDestinationChangedListener(this)
          }
  </code></pre>
  <p>Xml (tried with <code>&lt;fragment/&gt;</code> too):</p>
  <pre><code>&lt;androidx.fragment.app.FragmentContainerView
                  android:id=&quot;@+id/container&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
                  app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p><a href="https://issuetracker.google.com/issues/161825212" rel="nofollow noreferrer">Google issue tracker</a> (has a reproducible sample)</p>