hello, With the new navHost how do you pass data t...
# android
f
hello, With the new navHost how do you pass data to an activity destination? With composable you can use the NamedNavArguments. But these seem not to be available for activities? Is there a way to pass parcelable data that you could put in the intent of the activity you are starting?
😶 2
c
If you're referring to Navigation with Compose, the documentation has the answer:
Define a navigation graph with a NavHost in Compose using Compose destinations. This is possible only if all of the screens in the navigation graph are composables.
https://developer.android.com/jetpack/compose/navigation#interoperability So no, it's not possible to navigate from a pure-Compose nav graph to an Activity or Fragment destination. If you need that, then you need to follow the "hybrid" approach, also described in that same documentation second, or else handle the navigation outside of the Navigation Component, where you can pass data through the Intent as normal
They have added dsl for activity destinations and fragment destinations. The question was about this.