NavHostController

public class NavHostController extends NavController

Object
   ↳ NavController
     ↳ NavHostController
Known direct subclasses
TestNavHostController

Subclass of NavHostController that offers additional APIs for testing Navigation.


Subclass of NavController that offers additional APIs for use by a NavHost to connect the NavController to external dependencies.

Apps should generally not construct controllers, instead obtain a relevant controller directly from a navigation host via NavHost.getNavController or by using one of the utility methods on the Navigation class.

Summary

Public constructors

Public methods

final void
enableOnBackPressed(boolean enabled)

Set whether the NavController should handle the system Back button events via the registered OnBackPressedDispatcher.

final void

Sets the host's LifecycleOwner.

final void

Sets the host's OnBackPressedDispatcher.

final void

Sets the host's ViewModelStore used by the NavController to store ViewModels at the navigation graph level.

Inherited methods

From class NavController
void

Adds an OnDestinationChangedListener to this controller to receive a callback whenever the currentDestination or its arguments change.

final @MainThread boolean