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.
si...@sentbe.com <si...@sentbe.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
Description
Component used: Navigation
Version used: 2.5.3
Devices/Android versions reproduced on: Pixel 3a API 33
If this is a bug in the library, we would appreciate if you could attach:
Sample project to trigger the issue. A screenrecord or screenshots showing the issue (if UI related). I used jetpack compose navigation for nested graph. here my project structure. If this is a bug in the library, we would appreciate if you could attach:
I used jetpack compose navigation for nested graph. here my project structure.
// top level navHost
new screen with bottom navigation bar
A,B,C Screen in tempGraph
Presumably error source !!
!!! The funny thing is that it works just fine for normal types. (only custom type) !!!
Exception Log