of Navigation” and Navigation UI that implements this Decoupling of navigation from Activities and Fragments with NavController What the Navigation Component provides
own purposes Default implementation: Fragments, many improvements made in androidx. ActivityDestination is also provided Single activity to host NavHostFragment
your ViewModel!) // Navigate by id, findNavController is an extension provided by // navigation-fragment-ktx findNavController().navigate(R.id.event_list) // Go back findNavController().popBackStack() // Navigate with Directions findNavController().navigate(AttendeeListFragmentDirections.actionEventList())
super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Use the built-in ActionBar without a drawer setupActionBarWithNavController(findNavController(R.id.nav_host_fragment), null) }
super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val navController = findNavController(R.id.nav_host_fragment) // Configure the top level destinations (e.g. no back button) val appBarConfiguration = AppBarConfiguration(setOf(R.id.main_fragment, R.id.second_fragment)) findViewById<Toolbar>(R.id.toolbar) .setupWithNavController(navController, appBarConfiguration) }
https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSam ple Requires support for multiple backstacks in Fragments
does a “replace” Return a result like startActivityForResult → modify ViewModel state Nothing specific provided for “master-detail”; nesting NavHostFragments works.