# NavHostController

Artifact: [androidx.navigation:navigation-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavHostController.+class:androidx.navigation.NavHostController) Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

*** ** * ** ***


```
public class NavHostController extends NavController
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.navigation.NavController](https://developer.android.com/reference/androidx/navigation/NavController) ||
|   | ↳ | [androidx.navigation.NavHostController](https://developer.android.com/reference/androidx/navigation/NavHostController) |

Known direct subclasses [TestNavHostController](https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController)

|---|---|
| `https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController` | Subclass of `https://developer.android.com/reference/androidx/navigation/NavHostController` that offers additional APIs for testing Navigation. |

*** ** * ** ***

Subclass of `https://developer.android.com/reference/androidx/navigation/NavController` that offers additional APIs for use by a `https://developer.android.com/reference/androidx/navigation/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 `https://developer.android.com/reference/androidx/navigation/NavHost#navController()` or by using one of the utility methods on the `https://developer.android.com/reference/androidx/navigation/Navigation` class.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/navigation/NavHostController#NavHostController()()` |
| `https://developer.android.com/reference/androidx/navigation/NavHostController#NavHostController(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/navigation/NavHostController#enableOnBackPressed(kotlin.Boolean)(boolean enabled)` Set whether the NavController should handle the system Back button events via the registered `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher`. |
| `final void` | `https://developer.android.com/reference/androidx/navigation/NavHostController#setLifecycleOwner(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Sets the host's `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |
| `final void` | `https://developer.android.com/reference/androidx/navigation/NavHostController#setOnBackPressedDispatcher(androidx.activity.OnBackPressedDispatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher dispatcher)` Sets the host's `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher`. |
| `final void` | `https://developer.android.com/reference/androidx/navigation/NavHostController#setViewModelStore(androidx.lifecycle.ViewModelStore)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/ViewModelStore viewModelStore)` Sets the host's ViewModelStore used by the NavController to store ViewModels at the navigation graph level. |

### Inherited methods

From [androidx.navigation.NavController](https://developer.android.com/reference/androidx/navigation/NavController) `void` `https://developer.android.com/reference/androidx/navigation/NavController#addOnDestinationChangedListener(androidx.navigation.NavController.OnDestinationChangedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener listener
)`

Adds an `https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener` to this controller to receive a callback whenever the `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or its arguments change.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack()()`

Clears any saved state associated with KClass `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack()` that was previously saved via `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when using a `saveState` value of `true`.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId)`

Clears any saved state associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Int)` that was previously saved via `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when using a `saveState` value of `true`.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.reflect.KClass)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> route)`

Clears any saved state associated with KClass `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.reflect.KClass)` that was previously saved via `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when using a `saveState` value of `true`.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull T route)`

Clears any saved state associated with KClass `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Any)` that was previously saved via `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when using a `saveState` value of `true`.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route)`

Clears any saved state associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.String)` that was previously saved via `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when using a `saveState` value of `true`.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkBuilder` `https://developer.android.com/reference/androidx/navigation/NavController#createDeepLink()()`

Create a deep link to a destination within this NavController.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry()()`

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId)`

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a destination id.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.reflect.KClass)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> route)`

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a `https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.reflect.KClass)` from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull T route)`

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a route from an Object.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route)`

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a route.
`https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `https://developer.android.com/reference/androidx/navigation/NavController#getCurrentBackStackEntry()()`

The topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>` `https://developer.android.com/reference/androidx/navigation/NavController#getCurrentBackStackEntryFlow()()`

A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` that will emit the currently active `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` whenever it changes.
`https://developer.android.com/reference/androidx/navigation/NavDestination` `https://developer.android.com/reference/androidx/navigation/NavController#getCurrentDestination()()`

The current destination.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#getGraph()()`

The topmost navigation graph associated with this NavController.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavInflater` `https://developer.android.com/reference/androidx/navigation/NavController#getNavInflater()()`

The `https://developer.android.com/reference/androidx/navigation/NavInflater` for this controller.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavigatorProvider` `https://developer.android.com/reference/androidx/navigation/NavController#getNavigatorProvider()()`

The NavController's `https://developer.android.com/reference/androidx/navigation/NavigatorProvider`.
`https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` `https://developer.android.com/reference/androidx/navigation/NavController#getPreviousBackStackEntry()()`

The previous visible `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner` `https://developer.android.com/reference/androidx/navigation/NavController#getViewModelStoreOwner(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IdRes int navGraphId)`

Gets the `https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner` for a NavGraph.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavController#getVisibleEntries()()`

A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html` that will emit the currently visible `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` whenever they change.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#handleDeepLink(android.content.Intent)(https://developer.android.com/reference/android/content/Intent.html intent)`

Checks the given Intent for a Navigation deep link and navigates to the deep link if present.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#handleDeepLink(androidx.navigation.NavDeepLinkRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request)`

Checks the given NavDeepLinkRequest for a Navigation deep link and navigates to the destination if present.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink)`

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri).
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDirections)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions)`

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDeepLinkRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request)`

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IdRes int resId)`

Navigate to a destination from the current navigation graph.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(android.net.Uri,androidx.navigation.NavOptions)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink, https://developer.android.com/reference/androidx/navigation/NavOptions navOptions)`

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri).
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDirections,androidx.navigation.NavOptions)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions, https://developer.android.com/reference/androidx/navigation/NavOptions navOptions)`

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDirections,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDeepLinkRequest,androidx.navigation.NavOptions)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request, https://developer.android.com/reference/androidx/navigation/NavOptions navOptions)`

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Int,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/IdRes int resId, https://developer.android.com/reference/android/os/Bundle.html args)`

Navigate to a destination from the current navigation graph.
`final void` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Any,kotlin.Function1)(
@https://developer.android.com/reference/androidx/annotation/NonNull T route,
@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavOptionsBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder
)`

Navigate to a route from an Object in the current NavGraph.
`final void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.String,kotlin.Function1)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route,
@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavOptionsBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder
)`

Navigate to a route in the current NavGraph.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(android.net.Uri,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri).
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavDeepLinkRequest,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Int,android.os.Bundle,androidx.navigation.NavOptions)(@https://developer.android.com/reference/androidx/annotation/IdRes int resId, https://developer.android.com/reference/android/os/Bundle.html args, https://developer.android.com/reference/androidx/navigation/NavOptions navOptions)`

Navigate to a destination from the current navigation graph.
`final void` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Any,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull T route,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a route from an Object in the current NavGraph.
`final void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.String,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a route in the current NavGraph.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigate(kotlin.Int,android.os.Bundle,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/IdRes int resId,
https://developer.android.com/reference/android/os/Bundle.html args,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a destination from the current navigation graph.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()()`

Attempts to navigate up in the navigation hierarchy.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()()`

Attempts to pop the controller's back stack.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId, boolean inclusive)`

Attempts to pop the controller's back stack back to a specific destination.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean)(int destinationId, boolean inclusive)` `final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Boolean,kotlin.Boolean)(boolean inclusive, boolean saveState)`

Attempts to pop the controller's back stack back to a specific destination.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean,kotlin.Boolean)(
@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId,
boolean inclusive,
boolean saveState
)`

Attempts to pop the controller's back stack back to a specific destination.
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean,kotlin.Boolean)(int destinationId, boolean inclusive, boolean saveState)` `final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.reflect.KClass,kotlin.Boolean,kotlin.Boolean)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> route,
boolean inclusive,
boolean saveState
)`

Attempts to pop the controller's back stack back to a specific destination.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Any,kotlin.Boolean,kotlin.Boolean)(
@https://developer.android.com/reference/androidx/annotation/NonNull T route,
boolean inclusive,
boolean saveState
)`

Attempts to pop the controller's back stack back to a specific destination.
`final boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.String,kotlin.Boolean,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route, boolean inclusive, boolean saveState)`

Attempts to pop the controller's back stack back to a specific destination.
`void` `https://developer.android.com/reference/androidx/navigation/NavController#removeOnDestinationChangedListener(androidx.navigation.NavController.OnDestinationChangedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener listener
)`

Removes an `https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener` from this controller.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#restoreState(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html navState)`

Restores all navigation controller state from a SavedState.
`https://developer.android.com/reference/androidx/savedstate/SavedState` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#saveState()()`

Saves all navigation controller state to a SavedState.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#setGraph(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NavigationRes int graphResId)`

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified resource.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph value)`

The topmost navigation graph associated with this NavController.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph graph, https://developer.android.com/reference/android/os/Bundle.html startDestinationArgs)`

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified graph.
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavController#setGraph(kotlin.Int,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NavigationRes int graphResId, https://developer.android.com/reference/android/os/Bundle.html startDestinationArgs)`

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified resource.

## Public constructors

### NavHostController

```
public NavHostController()
```

### NavHostController

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

```
public NavHostController(@NonNull Context context)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | context for this controller |

## Public methods

### enableOnBackPressed

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

```
public final void enableOnBackPressed(boolean enabled)
```

Set whether the NavController should handle the system Back button events via the registered `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher`.

| Parameters |
|---|---|
| `boolean enabled` | True if the NavController should handle system Back button events. |

### setLifecycleOwner

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

```
public final void setLifecycleOwner(@NonNull LifecycleOwner owner)
```

Sets the host's `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` associated with the containing `https://developer.android.com/reference/androidx/navigation/NavHost`. |

### setOnBackPressedDispatcher

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

```
public final void setOnBackPressedDispatcher(@NonNull OnBackPressedDispatcher dispatcher)
```

Sets the host's `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher`. If set, NavController will register a `https://developer.android.com/reference/androidx/navigation/NavController#onBackPressedCallback()` to handle system Back button events.

You must explicitly called `https://developer.android.com/reference/androidx/navigation/NavHostController#setLifecycleOwner(androidx.lifecycle.LifecycleOwner)` before calling this method as the owner set there will be used as the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` for registering the `https://developer.android.com/reference/androidx/navigation/NavController#onBackPressedCallback()`.

You can dynamically enable and disable whether the NavController should handle the system Back button events by calling `https://developer.android.com/reference/androidx/navigation/NavHostController#enableOnBackPressed(kotlin.Boolean)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher dispatcher` | The `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher` associated with the containing `https://developer.android.com/reference/androidx/navigation/NavHost`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if you have not called `https://developer.android.com/reference/androidx/navigation/NavHostController#setLifecycleOwner(androidx.lifecycle.LifecycleOwner)` before calling this method. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavHostController#setLifecycleOwner(androidx.lifecycle.LifecycleOwner)` |   |

### setViewModelStore

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.1.0)

```
public final void setViewModelStore(@NonNull ViewModelStore viewModelStore)
```

Sets the host's ViewModelStore used by the NavController to store ViewModels at the navigation graph level. This is required to call `getViewModelStoreOwner` and should generally be called for you by your `https://developer.android.com/reference/androidx/navigation/NavHost`.

You must call this method before `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)` or similar methods, because the `https://developer.android.com/reference/androidx/lifecycle/ViewModelStore` set here will be used by the created `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` items.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/ViewModelStore viewModelStore` | ViewModelStore used to store ViewModels at the navigation graph level |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if this method is called when graph was already set via `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)` or similar methods. |