0

I have an Android navigation setup with two navigation graphs. The first graph contains two items in the bottom navigation: "Item one" and "Item two." "Item one" points to "Navigation Graph1," while "Item two" points to a nested navigation graph, "NEsted Navigation Graph2."

The issue I'm facing is that when I navigate to "NEsted Navigation Graph2" by selecting "Item two," and then later return to "NEsted Navigation Graph2" by selecting "Item one" and then "Item two" again, the state is retained on the last fragment I visited within the nested graph.

Desired Behavior: What I want to achieve is that whenever "NEsted Navigation Graph2" (Item two) is selected, it should always navigate to the home fragment (let's call it "HomeFragmentNested") of the nested graph, effectively resetting its state.

Current setup (simplified):

Bottom Navigation: Item one -> Navigation Graph1 Item two -> NEsted Navigation Graph2

NEsted Navigation Graph2:

  • HomeFragmentNested
  • FragmentA
  • FragmentB
  • ... (other fragments and actions within the nested graph)

How can I modify the navigation setup to ensure that whenever "NEsted Navigation Graph2" (Item two) is selected from the bottom navigation, it always navigates back to "HomeFragmentNested," regardless of the previously visited state within the nested graph? Is there a way to use popUpTo and popUpToInclusive attributes to achieve this? If so, how should I set up these attributes for my destinations within the nested graph?

Ashutosh Soni
  • 855
  • 3
  • 9
  • 22

0 Answers0