Navigating in onCreate method like so:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.magic_mile_host)
setSupportActionBar(toolbar_start_test)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp)
navController = findNavController(R.id.nav_host_magic_mile)
navigateToMyTests()
}
Here is my navigateToMyTests()
implementation
navController.navigate(R.id.myTestsFragment)
The problem only appears when i invoke this function immediately.
The problem is when I'm on fragment which i came from myTestsFragment
. After rotating screen the current fragment is not restored but myTestsFragment
is restored always.
The reason why I did this way is because i want to ommit my startDestination in nav graph in certain situation. Could you explain me why it's happening and maybe help me to come up with other solution to this problem?