I'm using Android Navigation Architecture Component with single activity, multiple destinations. I'm initializing some of the static Variables in SplashFragment which is the "startDestination" of my NavGraph. But I'm facing problem, when app goes in background for long time (probably some memory is claimed back by Android OS), due to which some of these static variables (or Singleton Classes) got reset. When app comes in foreground, I was expecting my Activity to start with SplashFragment (start destination) again, because it is re-created (with onCreate() method called). But due to some Navigation Saving State Mechanism, it's starting from last Destination. I want to know how to clear navigation state during app Hot Start, so that it starts from Start Destination.
I found a quick solution to this problem: During App Hot Start, Activity.onCreate() is called with "savedInstanceState" which also contains Navigation state. In my case I don't want to retain anything. Therefore I simply called super.onCreate(null) and hence not passing "savedInstanceState" variable at all.
We can also alter/clear some of the states in "savedInstanceState" variable which we don't want to restore.