Status Update
Comments
jb...@google.com <jb...@google.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
Description
Version used: 2.1.0-alpha04
Devices/Android versions reproduced on: N/A
To reproduce:
1. Click on Leaderboard
2. Click on any of the Names
3. Click Back -> Leaderboard
4. Click on any of the Names
5. Click Back -> Leaderboard
6. Click Back -> Nothing happens but should open Title Screen
Moving the deepLink out of the startFragment of the subgraph and to the graph itself fixes this. Seems like the nav_graph destination for the subgraph is not properly popped at some point.