Skip to content

Instantly share code, notes, and snippets.

@Sinarahimi
Created January 8, 2022 07:23
Show Gist options
  • Save Sinarahimi/baf46adb763b1be185c27b05db0b30a8 to your computer and use it in GitHub Desktop.
Save Sinarahimi/baf46adb763b1be185c27b05db0b30a8 to your computer and use it in GitHub Desktop.
Pass data to Start Navigation
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val extras = intent.extras
val finalHost = NavHostFragment.create(R.navigation.main_navigation , bundleOf("Key' to "value"))
supportFragmentManager.beginTransaction()
.replace(R.id.mainNavHost, finalHost)
.setPrimaryNavigationFragment(finalHost) // equivalent to app:defaultNavHost="true"
.commit()
@Sinarahimi
Copy link
Author

When you wanted to pass args to start Destination in your Navigation Component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment