简体   繁体   中英

Navigate to a independent fragment with navigation

I'm working on a app that contains a background service, which might send errors or calls for action to the user ( in app, so no notification). for that I've designed some Fragments after the dialogs got to complex. Some use DataBinding. But I'm stuck how I should integrate them in the Navigation correctly.

It feels wrong to create a action from any fragment in graph to the target fragment. So I've searched for a way how to navigate to a fragment that might not even included in the NavGaph. Deep link does not seems to be right as this would open up the access to that fragment to the world, what's not my desire.

In other words I have Fragments A, B, C and D. A, B, and C are in a NavigationGraph. D is outside of that / not included in the NavigationGraph. The Goal is to navigate from A, B and C to D as clean as possible. Its not possible to add a action from any Fragment (A, B, C) to D in the described NavigationGraph or in a separate one, as this would result in setting around 30 additional actions. Neither should the Fragment D accessible from outside of the app, via deeplink or similar.

Global actions are meant for this situation: you have one destination ( Fragment D) which can be reached from every other destination ( Fragment s A to C).

The destination for Fragment D and the corresponding global action can be added to the same navigation graph as the other fragment destinations, and the global action can only be used inside your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM