good afternoon composing team... is it possible to...
# compose
t
good afternoon composing team... is it possible to share a compose navigation graph between multiple Activities? my application has two acitvities that i wish to use the same nav graph. I have a main Home screen which is used for the majority of user triggered interactions however my app is also accessed via local notifications where i deeplink into another Activity which all works fine, however when the user clicks BACK or UP they are returned to the device Home Page where i wish for them to stay in my application
p
I would place AnotherActivity as one destination of the MainActivity(the one that contains HomeScreen) main_graph. Then would register MainActivity as the entry point for all notifications click intents. In the MainActivity having a NotificationHandler helper class that will determine where to go next based on the notification metadata. That way you can build the desired path/route from the notification. Under normal circumstances, one graph for the whole App is more than enough.
t
yes, that would work however there is one wrinkle in that the
AnotherActivity
does not have the same app bar as all the other screen under
MainActivity
in fact
AnotherActivity
does have an app bar at all and with my
MainActivity
having a backdrop for the user to navigate around the app
p
Well that is UI stuff, is up to you if you want to keep the same topbar or use a different one. If your concern is to know whether to provide back navigation in
AnotherActivity
you could workaround it by passing that information in the input arguments. Pass a isRoot: Boolean field to indicate if you are launching it from another Activity or is the only Activity in the stack.