# TestNavHostController

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

*** ** * ** ***


```
public final class TestNavHostController extends NavHostController
```

<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) ||
|   |   | ↳ | [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.

## Summary

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

| ### Public methods |
|---|---|
| `final @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/testing/TestNavHostController#getBackStack()()` Gets an immutable copy of the `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` currently on the back stack. |
| `final void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController#setCurrentDestination(kotlin.Int,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/IdRes int destId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html args)` Navigate directly to any destination on the current `https://developer.android.com/reference/androidx/navigation/NavGraph` via an explicit deep link. |
| `final void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController#setCurrentDestination(kotlin.String,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html destRoute, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html args)` Navigate directly to any destination on the current `https://developer.android.com/reference/androidx/navigation/NavGraph` via an explicit deep link. |

### 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.
From [androidx.navigation.NavHostController](https://developer.android.com/reference/androidx/navigation/NavHostController) `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.

## Public constructors

### TestNavHostController

```
public TestNavHostController()
```

### TestNavHostController

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

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

## Public methods

### getBackStack

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

```
public final @NonNull List<@NonNull NavBackStackEntry> getBackStack()
```

Gets an immutable copy of the `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` currently on the back stack.

### setCurrentDestination

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

```
public final void setCurrentDestination(@IdRes int destId, @NonNull Bundle args)
```

Navigate directly to any destination on the current `https://developer.android.com/reference/androidx/navigation/NavGraph` via an explicit deep link. If an implicit deep link exists for this destination use #navigate(Uri) instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int destId` | The destination id to navigate to. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html args` | The arguments to pass to the destination. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the `https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController#setCurrentDestination(kotlin.Int,android.os.Bundle)` does not exist on the NavGraph. |

### setCurrentDestination

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

```
public final void setCurrentDestination(@NonNull String destRoute, @NonNull Bundle args)
```

Navigate directly to any destination on the current `https://developer.android.com/reference/androidx/navigation/NavGraph` via an explicit deep link. If an implicit deep link exists for this destination use #navigate(Uri) instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html destRoute` | The destination route to navigate to. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html args` | The arguments to pass to the destination. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the `https://developer.android.com/reference/androidx/navigation/testing/TestNavHostController#setCurrentDestination(kotlin.String,android.os.Bundle)` does not exist on the NavGraph. |