Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
So there does seem to be a bug in Navigation that causes this to fail.
When it navigates with popUpTo
and removes SecondFragment
, that removal in fragment is set for a frame later and before it is actually removed the navigate call in the onViewCreated
of SecondFragment
enqueues another call to add it back. But we still need to destroy SecondDetailFragment
which ends up marking the NavBackStackEntry
associated with SecondFragment
as complete before navigation has received the call from the fragment that it has been added back. So by the time it hits this check, the SecondFragment
is in the correct state, but Navigation has no way of referencing it so it assumes that it is not associated with an entry.
But this is not the way this type of situation should be implemented. Instead of having the destinations as part of the NavGraph, they should:
- be managed by the childFragmentManager of
SecondFragment
. So instead of going back toSecondFragment
just to go somewhere else, each of the fragments take the entire content ofSecondFragment
and are swapped out. - for some sort of a/b testing, set different graphs in the Activity. The graphs would keep the same
SecondFragment
id, but swap out the names and then you choose the correct graph based on the condition.
Description
If you are creating a new Android Gradle Plugin Ninja build script, this is the place to discuss and log small issues.
For larger issues, please open Android Studio and click Help/Submit Feedback. Be sure to reference 'Custom C/C++ Build Systems' to help direct the bug.
Alternatively, you can create a bug with this link , but it will have less diagnostic information.