Building an artificial back stack with the Android Navigation component
Context
Backwards navigation with Navigation Component isn't a mystery, is it? We don't have to do anything, we have it for free.
But, what if you want to navigate straight to a specific destination? And be able to navigate back to the start destinat...
erikmedina.dev5 min read
Álefe Lucas
Let's introduce a difficulty: suppose your SecondFragment can also be accessed by another flow unrelated to the HomeFragment. Like this: OutsiderFragment -> SecondFragment If you press the back button in the SecondFragment in this stack, you wanna go to the OutsiderFragment, not the HomeFragment. Thus, SecondFragment must NOT assume it always came from the HomeFragment via FirstFragment. An extra point if this behavior can be manager without SecondFragment knowing from where it came from.