Architecture-components-samples: How to use global action if the sample use 3 navigation graphs?

Created on 15 Apr 2019  路  9Comments  路  Source: android/architecture-components-samples

How to use global action if the sample use 3 navigation graphs?

Most helpful comment

I'm also facing this problem, but in my use case the 3 out of 5 tabs that I need are the same fragment, so I cannot use different nav graphs. Is there a way to use the same nav graph for all the tabs of the bottom navigation but still have different back stacks?

I'm close to a point of dropping the Navigation Component altogether, I don't think it's made to handle complex navigation cases.

All 9 comments

I have same issue, did you fix it?

Well.... yes and no.

There is no real global action, that could work for all navgraph files,
so for example in my case, to navigate to common dialog fragment, i put it in another navigraph file,
then all other navgraph files should include it and make action to the included navgraph

But that means duplicated nested graph and duplicated args if needed. Since the common fragments (dialog or webview) are really essential, and duplicated is not so good. Are there any better solutions?

Yeah not best solution, and i even caught on cyclic nav graph include crash because of this, need better solution

I'm also facing this problem, but in my use case the 3 out of 5 tabs that I need are the same fragment, so I cannot use different nav graphs. Is there a way to use the same nav graph for all the tabs of the bottom navigation but still have different back stacks?

I'm close to a point of dropping the Navigation Component altogether, I don't think it's made to handle complex navigation cases.

@deckyfx How did you solve the cyclic nav graph include crash?

Hummm... I am looking for the better solution too. Did anyone solve it?

I've ended up creating 3 of the same fragment (that point to the same class) as destinations in my Nav Graph where each one of them gets the different params I need. Not the cleanest solution, but it works for now.

I also encountered this issue and was looking for a solution, stumbled upon this SO answer

https://stackoverflow.com/questions/62591099/using-global-actions-with-multiple-graphs-in-jetpack-navigation

I wonder if that's the only reasonable solution for today?

Was this page helpful?
0 / 5 - 0 ratings