# NavController

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

*** ** * ** ***


```
public class NavController
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavHostController` | 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. |

Known indirect 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. |

*** ** * ** ***

NavController manages app navigation within a `https://developer.android.com/reference/androidx/navigation/NavHost`.

Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the `https://developer.android.com/reference/androidx/navigation/Navigation` class rather than create a controller directly.

Navigation flows and destinations are determined by the `https://developer.android.com/reference/androidx/navigation/NavGraph` owned by the controller. These graphs are typically [inflated](https://developer.android.com/reference/androidx/navigation/NavInflater) from an Android resource, but, like views, they can also be constructed or combined programmatically or for the case of dynamic navigation structure. (For example, if the navigation structure of the application is determined by live data obtained' from a remote server.)

## Summary

| ### Nested types |
|---|
| `public fun interface https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener` OnDestinationChangedListener receives a callback when the `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or its arguments change. |

| ### Constants |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigation/NavController#KEY_DEEP_LINK_INTENT()` The `https://developer.android.com/reference/android/content/Intent.html` that triggered a deep link to the current destination. |

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

| ### Public methods |
|---|---|
| `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. |
| `static final void` | `@https://developer.android.com/reference/androidx/navigation/NavDeepLinkSaveStateControl https://developer.android.com/reference/androidx/navigation/NavController#enableDeepLinkSaveState(kotlin.Boolean)(boolean saveState)` By default, `https://developer.android.com/reference/androidx/navigation/NavController#handleDeepLink(androidx.navigation.NavDeepLinkRequest)` will automatically add calls to `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` with a `saveState` of `true` when the deep link takes you to another graph (e.g., a different navigation graph than the one your start destination is in). |
| `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. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.[createGraph](https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Int,kotlin.Int,kotlin.Function1))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/IdRes int id, @https://developer.android.com/reference/androidx/annotation/IdRes int startDestination, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` **This method is deprecated.** Use routes to create your NavGraph instead |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.[createGraph](https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Int,kotlin.Int,kotlin.Function1))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/IdRes int id, @https://developer.android.com/reference/androidx/annotation/IdRes int startDestination, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` **This method is deprecated.** Use routes to create your dynamic NavGraph instead |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.String,kotlin.String,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html startDestination, 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/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.String,kotlin.String,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html startDestination, 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/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html startDestination, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html startDestination, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @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 ?> startDestination, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @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 ?> startDestination, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder )` Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).navigateUp(androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration appBarConfiguration )` Handles the Up button by delegating its behavior to the given `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavControllerKt.https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).navigateUp(androidx.customview.widget.Openable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController receiver, https://developer.android.com/reference/androidx/customview/widget/Openable drawerLayout )` Handles the Up button by delegating its behavior to the given `https://developer.android.com/reference/androidx/navigation/NavController`. |

## Constants

### KEY_DEEP_LINK_INTENT

```
public static final @NonNull String KEY_DEEP_LINK_INTENT
```

The `https://developer.android.com/reference/android/content/Intent.html` that triggered a deep link to the current destination.

## Public constructors

### NavController

```
public NavController()
```

### NavController

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

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

## Public methods

### addOnDestinationChangedListener

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

```
public void addOnDestinationChangedListener(
    @NonNull 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.

The current destination, if any, will be immediately sent to your listener.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener listener` | the listener to receive events |

### clearBackStack

```
@MainThread
public final boolean <T extends Object> 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`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The route from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` of the destination previously used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` with a `saveState`value of `true`. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Returns |
|---|---|
| `boolean` | true if the saved state of the stack associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack()` was cleared. |

### clearBackStack

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

```
@MainThread
public final boolean clearBackStack(@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`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId` | The ID of the destination previously used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` with a `saveState`value of `true` |

| Returns |
|---|---|
| `boolean` | true if the saved state of the stack associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Int)` was cleared. |

### clearBackStack

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

```
@MainThread
public final boolean <T extends Object> clearBackStack(@NonNull KClass<@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`.

| Parameters |
|---|---|
| `@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` | The route from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` of the destination previously used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` with a `saveState`value of `true`. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Returns |
|---|---|
| `boolean` | true if the saved state of the stack associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.reflect.KClass)` was cleared. |

### clearBackStack

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

```
@MainThread
public final boolean <T extends Object> clearBackStack(@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`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T route` | The route from an Object of the destination previously used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` with a `saveState`value of `true`. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Returns |
|---|---|
| `boolean` | true if the saved state of the stack associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.Any)` was cleared. |

### clearBackStack

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

```
@MainThread
public final boolean clearBackStack(@NonNull String 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`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route` | The route of the destination previously used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` with a `saveState` value of `true`. May contain filled in arguments as long as it is exact match with route used with `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()`. |

| Returns |
|---|---|
| `boolean` | true if the saved state of the stack associated with `https://developer.android.com/reference/androidx/navigation/NavController#clearBackStack(kotlin.String)` was cleared. |

### createDeepLink

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

```
public @NonNull NavDeepLinkBuilder createDeepLink()
```

Create a deep link to a destination within this NavController.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkBuilder` | a `https://developer.android.com/reference/androidx/navigation/NavDeepLinkBuilder` suitable for constructing a deep link |

### enableDeepLinkSaveState

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

```
@NavDeepLinkSaveStateControl
public static final void enableDeepLinkSaveState(boolean saveState)
```

By default, `https://developer.android.com/reference/androidx/navigation/NavController#handleDeepLink(androidx.navigation.NavDeepLinkRequest)` will automatically add calls to `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` with a `saveState` of `true` when the deep link takes you to another graph (e.g., a different navigation graph than the one your start destination is in).

You can disable this behavior by passing `false` for `https://developer.android.com/reference/androidx/navigation/NavController.Companion#enableDeepLinkSaveState(kotlin.Boolean)`.

### getBackStackEntry

```
public final @NonNull NavBackStackEntry <T extends Object> 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`.

This is always safe to use with `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or `https://developer.android.com/reference/androidx/navigation/NavDestination#parent()` or grandparent navigation graphs as these destinations are guaranteed to be on the back stack.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | route from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` of a destination that exists on the back stack. The target NavBackStackEntry's `https://developer.android.com/reference/androidx/navigation/NavDestination` must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the destination is not on the back stack |

### getBackStackEntry

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

```
public @NonNull NavBackStackEntry getBackStackEntry(@IdRes int destinationId)
```

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a destination id.

This is always safe to use with `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or `https://developer.android.com/reference/androidx/navigation/NavDestination#parent()` or grandparent navigation graphs as these destinations are guaranteed to be on the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId` | ID of a destination that exists on the back stack |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the destination is not on the back stack |

### getBackStackEntry

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

```
public final @NonNull NavBackStackEntry <T extends Object> getBackStackEntry(@NonNull KClass<@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`.

This is always safe to use with `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or `https://developer.android.com/reference/androidx/navigation/NavDestination#parent()` or grandparent navigation graphs as these destinations are guaranteed to be on the back stack.

| Parameters |
|---|---|
| `@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` | route from the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` of destination `https://developer.android.com/reference/androidx/navigation/NavController#getBackStackEntry(kotlin.reflect.KClass)` that exists on the back stack. The target NavBackStackEntry's `https://developer.android.com/reference/androidx/navigation/NavDestination` must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the destination is not on the back stack |

### getBackStackEntry

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

```
public final @NonNull NavBackStackEntry <T extends Object> getBackStackEntry(@NonNull T route)
```

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a route from an Object.

This is always safe to use with `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or `https://developer.android.com/reference/androidx/navigation/NavDestination#parent()` or grandparent navigation graphs as these destinations are guaranteed to be on the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T route` | route from an Object of a destination that exists on the back stack. The target NavBackStackEntry's `https://developer.android.com/reference/androidx/navigation/NavDestination` must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the destination is not on the back stack |

### getBackStackEntry

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

```
public final @NonNull NavBackStackEntry getBackStackEntry(@NonNull String route)
```

Gets the topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for a route.

This is always safe to use with `https://developer.android.com/reference/androidx/navigation/NavController#currentDestination()` or `https://developer.android.com/reference/androidx/navigation/NavDestination#parent()` or grandparent navigation graphs as these destinations are guaranteed to be on the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route` | route of a destination that exists on the back stack. May contain filled in arguments as long as it is exact match with route used to navigate. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the destination is not on the back stack |

### getCurrentBackStackEntry

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

```
public NavBackStackEntry getCurrentBackStackEntry()
```

The topmost `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` | the topmost entry on the back stack or null if the back stack is empty |

### getCurrentBackStackEntryFlow

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

```
public final @NonNull Flow<@NonNull NavBackStackEntry> 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. If there is no active `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`, no item will be emitted.

### getCurrentDestination

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

```
public NavDestination getCurrentDestination()
```

The current destination.

### getGraph

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

```
@MainThread
public @NonNull NavGraph getGraph()
```

The topmost navigation graph associated with this NavController.

When this is set any current navigation graph data (including back stack) will be replaced.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if called before `setGraph()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)` |   |

### getNavInflater

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

```
public @NonNull NavInflater getNavInflater()
```

The `https://developer.android.com/reference/androidx/navigation/NavInflater` for this controller.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavInflater` | inflater for loading navigation resources |

### getNavigatorProvider

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

```
public @NonNull NavigatorProvider getNavigatorProvider()
```

The NavController's `https://developer.android.com/reference/androidx/navigation/NavigatorProvider`. All `https://developer.android.com/reference/androidx/navigation/Navigator` used to construct the `https://developer.android.com/reference/androidx/navigation/NavGraph` for this nav controller should be added to this navigator provider before the graph is constructed.

This can only be set before the graph is set via `setGraph()`.

Generally, the Navigators are set for you by the `https://developer.android.com/reference/androidx/navigation/NavHost` hosting this NavController and you do not need to manually interact with the navigator provider.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If this set called after `setGraph()` |

### getPreviousBackStackEntry

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

```
public NavBackStackEntry getPreviousBackStackEntry()
```

The previous visible `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`.

This skips over any `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` that is associated with a `https://developer.android.com/reference/androidx/navigation/NavGraph`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` | the previous visible entry on the back stack or null if the back stack has less than two visible entries |

### getViewModelStoreOwner

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

```
public @NonNull ViewModelStoreOwner getViewModelStoreOwner(@IdRes int navGraphId)
```

Gets the `https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner` for a NavGraph. This can be passed to `https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider` to retrieve a ViewModel that is scoped to the navigation graph - it will be cleared when the navigation graph is popped off the back stack.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int navGraphId` | ID of a NavGraph that exists on the back stack |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if called before the `https://developer.android.com/reference/androidx/navigation/NavHost` has called `https://developer.android.com/reference/androidx/navigation/NavHostController#setViewModelStore(androidx.lifecycle.ViewModelStore)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the NavGraph is not on the back stack |

### getVisibleEntries

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

```
public final @NonNull StateFlow<@NonNull List<@NonNull NavBackStackEntry>> 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. If there is no visible `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`, this will be set to an empty list.

- `CREATED` entries are listed first and include all entries that are in the process of completing their exit transition. Note that this can include entries that have been popped off the Navigation back stack.

- `STARTED` entries on the back stack are next and include all entries that are running their enter transition and entries whose destination is partially covered by a `FloatingWindow` destination

- The last entry in the list is the topmost entry in the back stack and is in the `RESUMED` state only if its enter transition has completed. Otherwise it too will be `STARTED`.

Note that the `Lifecycle` of any entry cannot be higher than the containing Activity/Fragment - if the Activity is not `RESUMED`, no entry will be `RESUMED`, no matter what the transition state is.

### handleDeepLink

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

```
@MainThread
public boolean handleDeepLink(Intent intent)
```

Checks the given Intent for a Navigation deep link and navigates to the deep link if present. This is called automatically for you the first time you set the graph if you've passed in an `https://developer.android.com/reference/android/app/Activity.html` as the context when constructing this NavController, but should be manually called if your Activity receives new Intents in `https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)`.

The types of Intents that are supported include:

Intents created by `https://developer.android.com/reference/androidx/navigation/NavDeepLinkBuilder` or `https://developer.android.com/reference/androidx/navigation/NavController#createDeepLink()`. This assumes that the current graph shares the same hierarchy to get to the deep linked destination as when the deep link was constructed. Intents that include a `https://developer.android.com/reference/android/content/Intent.html#getData()`. This Uri will be checked against the Uri patterns in the `https://developer.android.com/reference/androidx/navigation/NavDeepLink` added via `https://developer.android.com/reference/androidx/navigation/NavDestination#addDeepLink(kotlin.String)`.

The `https://developer.android.com/reference/androidx/navigation/NavController#graph()` should be set before calling this method.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Intent.html intent` | The Intent that may contain a valid deep link |

| Returns |
|---|---|
| `boolean` | True if the navigation controller found a valid deep link and navigated to it. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if deep link cannot be accessed from the current destination |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavDestination#addDeepLink(kotlin.String)` |   |

### handleDeepLink

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

```
@MainThread
public final boolean handleDeepLink(@NonNull NavDeepLinkRequest request)
```

Checks the given NavDeepLinkRequest for a Navigation deep link and navigates to the destination if present.

The `https://developer.android.com/reference/androidx/navigation/NavController#graph()` should be set before calling this method.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request` | The request that contains a valid deep link, an action or a mimeType. |

| Returns |
|---|---|
| `boolean` | True if the navigation controller found a valid deep link and navigated to it. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if deep link cannot be accessed from the current destination |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavDestination#addDeepLink(kotlin.String)` |   |

### navigate

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

```
@MainThread
public void navigate(@NonNull Uri deepLink)
```

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri). `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink` | deepLink to the destination reachable from the current NavGraph |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavUri)` |   |

### navigate

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

```
@MainThread
public void navigate(@NonNull NavDirections directions)
```

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions` | directions that describe this navigation operation |

### navigate

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

```
@MainThread
public void navigate(@NonNull NavDeepLinkRequest request)
```

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`. `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request` | deepLinkRequest to the destination reachable from the current NavGraph |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given deep link request is invalid |

### navigate

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

```
@MainThread
public void navigate(@IdRes int resId)
```

Navigate to a destination from the current navigation graph. This supports both navigating via an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` and directly navigating to a destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int resId` | an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` id or a destination id to navigate to |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if there is no current navigation node |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the desired destination cannot be found from the current destination |

### navigate

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

```
@MainThread
public void navigate(@NonNull Uri deepLink, NavOptions navOptions)
```

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri). `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink` | deepLink to the destination reachable from the current NavGraph |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavUri)` |   |

### navigate

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

```
@MainThread
public void navigate(@NonNull NavDirections directions, NavOptions navOptions)
```

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions` | directions that describe this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |

### navigate

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

```
@MainThread
public void navigate(
    @NonNull NavDirections directions,
    @NonNull Navigator.Extras navigatorExtras
)
```

Navigate via the given `https://developer.android.com/reference/androidx/navigation/NavDirections`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDirections directions` | directions that describe this navigation operation |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the `https://developer.android.com/reference/androidx/navigation/Navigator` |

### navigate

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

```
@MainThread
public void navigate(@NonNull NavDeepLinkRequest request, NavOptions navOptions)
```

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`. `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request` | deepLinkRequest to the destination reachable from the current NavGraph |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given deep link request is invalid |

### navigate

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

```
@MainThread
public void navigate(@IdRes int resId, Bundle args)
```

Navigate to a destination from the current navigation graph. This supports both navigating via an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` and directly navigating to a destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int resId` | an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` id or a destination id to navigate to |
| `https://developer.android.com/reference/android/os/Bundle.html args` | arguments to pass to the destination |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if there is no current navigation node |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the desired destination cannot be found from the current destination |

### navigate

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

```
@MainThread
public final void <T extends Object> navigate(
    @NonNull T route,
    @NonNull Function1<@NonNull NavOptionsBuilder, Unit> builder
)
```

Navigate to a route from an Object in the current NavGraph. If an invalid route is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

The target NavDestination must have been created with route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`

If given `https://developer.android.com/reference/androidx/navigation/NavOptions` pass in `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldRestoreState()` `true`, any args passed here as part of the route will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T route` | route from an Object for the destination |
| `@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` | DSL for constructing a new `https://developer.android.com/reference/androidx/navigation/NavOptions` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given route is invalid |

### navigate

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

```
@MainThread
public final void navigate(
    @NonNull String route,
    @NonNull Function1<@NonNull NavOptionsBuilder, Unit> builder
)
```

Navigate to a route in the current NavGraph. If an invalid route is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

If `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldRestoreState()` is `true` for the given `https://developer.android.com/reference/androidx/navigation/NavOptions`, any args passed here as part of the route will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route` | route for the destination |
| `@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` | DSL for constructing a new `https://developer.android.com/reference/androidx/navigation/NavOptions` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given route is invalid |

### navigate

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

```
@MainThread
public void navigate(
    @NonNull Uri deepLink,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

Navigate to a destination via the given deep link [Uri](https://developer.android.com/reference/android/net/Uri). `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html deepLink` | deepLink to the destination reachable from the current NavGraph |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the Navigator |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#navigate(androidx.navigation.NavUri)` |   |

### navigate

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

```
@MainThread
public void navigate(
    @NonNull NavDeepLinkRequest request,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

Navigate to a destination via the given `https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest`. `https://developer.android.com/reference/androidx/navigation/NavDestination#hasDeepLink(androidx.navigation.NavUri)` should be called on `https://developer.android.com/reference/androidx/navigation/NavController#graph()` prior to calling this method to check if the deep link is valid. If an invalid deep link is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDeepLinkRequest request` | deepLinkRequest to the destination reachable from the current NavGraph |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the Navigator |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given deep link request is invalid |

### navigate

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

```
@MainThread
public void navigate(@IdRes int resId, Bundle args, NavOptions navOptions)
```

Navigate to a destination from the current navigation graph. This supports both navigating via an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` and directly navigating to a destination.

If given `https://developer.android.com/reference/androidx/navigation/NavOptions` pass in `https://developer.android.com/reference/androidx/navigation/NavOptions#restoreState()` `true`, any args passed here will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int resId` | an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` id or a destination id to navigate to |
| `https://developer.android.com/reference/android/os/Bundle.html args` | arguments to pass to the destination |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if there is no current navigation node |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the desired destination cannot be found from the current destination |

### navigate

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

```
@MainThread
public final void <T extends Object> navigate(
    @NonNull T route,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

Navigate to a route from an Object in the current NavGraph. If an invalid route is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

The target NavDestination must have been created with route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`

If given `https://developer.android.com/reference/androidx/navigation/NavOptions` pass in `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldRestoreState()` `true`, any args passed here as part of the route will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T route` | route from an Object for the destination |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the `https://developer.android.com/reference/androidx/navigation/Navigator` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given route is invalid |

### navigate

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

```
@MainThread
public final void navigate(
    @NonNull String route,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

Navigate to a route in the current NavGraph. If an invalid route is given, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown.

If `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldRestoreState()` is `true` for the given `https://developer.android.com/reference/androidx/navigation/NavOptions`, any args passed here as part of the route will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route` | route for the destination |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the `https://developer.android.com/reference/androidx/navigation/Navigator` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given route is invalid |

### navigate

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

```
@MainThread
public void navigate(
    @IdRes int resId,
    Bundle args,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

Navigate to a destination from the current navigation graph. This supports both navigating via an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` and directly navigating to a destination.

If given `https://developer.android.com/reference/androidx/navigation/NavOptions` pass in `https://developer.android.com/reference/androidx/navigation/NavOptions#restoreState()` `true`, any args passed here will be overridden by the restored args.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int resId` | an `https://developer.android.com/reference/androidx/navigation/NavDestination#getAction(kotlin.Int)` id or a destination id to navigate to |
| `https://developer.android.com/reference/android/os/Bundle.html args` | arguments to pass to the destination |
| `https://developer.android.com/reference/androidx/navigation/NavOptions navOptions` | special options for this navigation operation |
| `https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras` | extras to pass to the Navigator |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if navigation graph has not been set for this NavController |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the desired destination cannot be found from the current destination |

### navigateUp

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

```
@MainThread
public boolean navigateUp()
```

Attempts to navigate up in the navigation hierarchy. Suitable for when the user presses the "Up" button marked with a left (or start)-facing arrow in the upper left (or starting) corner of the app UI.

The intended behavior of Up differs from `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack()` when the user did not reach the current destination from the application's own task. e.g. if the user is viewing a document or link in the current app in an activity hosted on another app's task where the user clicked the link. In this case the current activity (determined by the context used to create this NavController) will be [finished](https://developer.android.com/reference/android/app/Activity#finish()) and the user will be taken to an appropriate destination in this app on its own task.

| Returns |
|---|---|
| `boolean` | true if navigation was successful, false otherwise |

### popBackStack

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

```
@MainThread
public boolean popBackStack()
```

Attempts to pop the controller's back stack. Analogous to when the user presses the system [Back](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK) button when the associated navigation host has focus.

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public boolean popBackStack(@IdRes int destinationId, boolean inclusive)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId` | The topmost destination to retain |
| `boolean inclusive` | Whether the given destination should also be popped. |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public boolean popBackStack(int destinationId, boolean inclusive)
```

### popBackStack

```
@MainThread
public final boolean <T extends Object> popBackStack(boolean inclusive, boolean saveState)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The topmost destination to retain with route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |
| `boolean inclusive` | Whether the given destination should also be popped. |
| `boolean saveState` | Whether the back stack and the state of all destinations between the current destination and `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Boolean,kotlin.Boolean)` should be saved for later restoration via `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setRestoreState(kotlin.Boolean)` or the `restoreState` attribute using the same `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Boolean,kotlin.Boolean)` (note: this matching ID is true whether `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Boolean,kotlin.Boolean)` is true or false). |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public boolean popBackStack(
    @IdRes int destinationId,
    boolean inclusive,
    boolean saveState
)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int destinationId` | The topmost destination to retain |
| `boolean inclusive` | Whether the given destination should also be popped. |
| `boolean saveState` | Whether the back stack and the state of all destinations between the current destination and the `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean,kotlin.Boolean)` should be saved for later restoration via `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setRestoreState(kotlin.Boolean)` or the `restoreState` attribute using the same `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean,kotlin.Boolean)` (note: this matching ID is true whether `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Int,kotlin.Boolean,kotlin.Boolean)` is true or false). |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public boolean popBackStack(int destinationId, boolean inclusive, boolean saveState)
```

### popBackStack

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

```
@MainThread
public final boolean <T extends Object> popBackStack(
    @NonNull KClass<@NonNull T> route,
    boolean inclusive,
    boolean saveState
)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `@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` | The topmost destination to retain with route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |
| `boolean inclusive` | Whether the given destination should also be popped. |
| `boolean saveState` | Whether the back stack and the state of all destinations between the current destination and `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.reflect.KClass,kotlin.Boolean,kotlin.Boolean)` should be saved for later restoration via `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setRestoreState(kotlin.Boolean)` or the `restoreState` attribute using the same `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.reflect.KClass,kotlin.Boolean,kotlin.Boolean)` (note: this matching ID is true whether `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.reflect.KClass,kotlin.Boolean,kotlin.Boolean)` is true or false). |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public final boolean <T extends Object> popBackStack(
    @NonNull T route,
    boolean inclusive,
    boolean saveState
)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T route` | The topmost destination to retain with route from an Object. The target NavDestination must have been created with route from `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html`. |
| `boolean inclusive` | Whether the given destination should also be popped. |
| `boolean saveState` | Whether the back stack and the state of all destinations between the current destination and the `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Any,kotlin.Boolean,kotlin.Boolean)` should be saved for later restoration via `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setRestoreState(kotlin.Boolean)` or the `restoreState` attribute using the same `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Any,kotlin.Boolean,kotlin.Boolean)` (note: this matching ID is true whether `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.Any,kotlin.Boolean,kotlin.Boolean)` is true or false). |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### popBackStack

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

```
@MainThread
public final boolean popBackStack(@NonNull String route, boolean inclusive, boolean saveState)
```

Attempts to pop the controller's back stack back to a specific destination.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html route` | The topmost destination to retain. May contain filled in arguments as long as it is exact match with route used to navigate. |
| `boolean inclusive` | Whether the given destination should also be popped. |
| `boolean saveState` | Whether the back stack and the state of all destinations between the current destination and the `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.String,kotlin.Boolean,kotlin.Boolean)` should be saved for later restoration via `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setRestoreState(kotlin.Boolean)` or the `restoreState` attribute using the same `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.String,kotlin.Boolean,kotlin.Boolean)` (note: this matching ID is true whether `https://developer.android.com/reference/androidx/navigation/NavController#popBackStack(kotlin.String,kotlin.Boolean,kotlin.Boolean)` is true or false). |

| Returns |
|---|---|
| `boolean` | true if the stack was popped at least once and the user has been navigated to another destination, false otherwise |

### removeOnDestinationChangedListener

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

```
public void removeOnDestinationChangedListener(
    @NonNull NavController.OnDestinationChangedListener listener
)
```

Removes an `https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener` from this controller. It will no longer receive callbacks.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController.OnDestinationChangedListener listener` | the listener to remove |

### restoreState

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

```
@CallSuper
public void restoreState(Bundle navState)
```

Restores all navigation controller state from a SavedState. This should be called before any call to `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)`.

State may be saved to a SavedState by calling `https://developer.android.com/reference/androidx/navigation/NavController#saveState()`. Restoring controller state is the responsibility of a `https://developer.android.com/reference/androidx/navigation/NavHost`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html navState` | SavedState to restore |

### saveState

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

```
@CallSuper
public SavedState saveState()
```

Saves all navigation controller state to a SavedState.

State may be restored from a SavedState returned from this method by calling `https://developer.android.com/reference/androidx/navigation/NavController#restoreState(androidx.savedstate.SavedState)`. Saving controller state is the responsibility of a `https://developer.android.com/reference/androidx/navigation/NavHost`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/savedstate/SavedState` | saved state for this controller |

### setGraph

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

```
@MainThread
@CallSuper
public void setGraph(@NavigationRes int graphResId)
```

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified resource. Any current navigation graph data (including back stack) will be replaced.

The inflated graph can be retrieved via `https://developer.android.com/reference/androidx/navigation/NavController#graph()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NavigationRes int graphResId` | resource id of the navigation graph to inflate |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#navInflater()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(kotlin.Int)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavController#graph()` |   |

### setGraph

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

```
@MainThread
@CallSuper
public void setGraph(@NonNull NavGraph value)
```

The topmost navigation graph associated with this NavController.

When this is set any current navigation graph data (including back stack) will be replaced.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if called before `setGraph()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)` |   |

### setGraph

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

```
@MainThread
@CallSuper
public void setGraph(@NonNull NavGraph graph, Bundle startDestinationArgs)
```

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified graph. Any current navigation graph data (including back stack) will be replaced.

The graph can be retrieved later via `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph graph` | graph to set |
| `https://developer.android.com/reference/android/os/Bundle.html startDestinationArgs` | arguments to send to the start destination of the graph |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(androidx.navigation.NavGraph,androidx.savedstate.SavedState)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavController#graph()` |   |

### setGraph

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

```
@MainThread
@CallSuper
public void setGraph(@NavigationRes int graphResId, Bundle startDestinationArgs)
```

Sets the `https://developer.android.com/reference/androidx/navigation/NavGraph` to the specified resource. Any current navigation graph data (including back stack) will be replaced.

The inflated graph can be retrieved via `https://developer.android.com/reference/androidx/navigation/NavController#graph()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NavigationRes int graphResId` | resource id of the navigation graph to inflate |
| `https://developer.android.com/reference/android/os/Bundle.html startDestinationArgs` | arguments to send to the start destination of the graph |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavController#navInflater()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavController#setGraph(kotlin.Int)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavController#graph()` |   |

## Extension functions

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavController.android.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.[createGraph](https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Int,kotlin.Int,kotlin.Function1))(
    @NonNull NavController receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use routes to create your NavGraph instead, use this instead:
>
> ```
> createGraph(startDestination = startDestination.toString(), route = id.toString()) { builder.invoke() }
> ```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int id` | the graph's unique id |
| `@https://developer.android.com/reference/androidx/annotation/IdRes int startDestination` | the route for the start destination |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-dynamic-features-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/dynamicfeatures/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.[createGraph](https://developer.android.com/reference/androidx/navigation/NavController#(androidx.navigation.NavController).createGraph(kotlin.Int,kotlin.Int,kotlin.Function1))(
    @NonNull NavController receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use routes to create your dynamic NavGraph instead, use this instead:
>
> ```
> createGraph(startDestination = startDestination.toString(), route = id.toString()) { builder.invoke() }
> ```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull String startDestination,
    String route,
    @NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html startDestination` | the route for the start destination |
| `https://developer.android.com/reference/java/lang/String.html route` | the route for the graph |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-dynamic-features-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/dynamicfeatures/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull String startDestination,
    String route,
    @NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html startDestination` | the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` in order to match. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route` | the graph's unique route from a `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/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap` | A mapping of KType to custom NavType\<\*\> in the `https://developer.android.com/reference/androidx/navigation/package-summary#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)`. May be empty if `https://developer.android.com/reference/androidx/navigation/package-summary#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)` does not use custom NavTypes. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-dynamic-features-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/dynamicfeatures/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html startDestination` | the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` in order to match. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route` | the graph's unique route from a `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/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap` | A mapping of KType to custom NavType\<\*\> in the `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/package-summary#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)`. May be empty if `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/package-summary#(androidx.navigation.NavController).createGraph(kotlin.Any,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)` does not use custom NavTypes. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull NavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph`

| Parameters |
|---|---|
| `@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 ?> startDestination` | the starting destination's route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` for this NavGraph. The respective NavDestination must be added as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` in order to match. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route` | the graph's unique route from a `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/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap` | A mapping of KType to custom NavType\<\*\> in the `https://developer.android.com/reference/androidx/navigation/package-summary#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)`. May be empty if `https://developer.android.com/reference/androidx/navigation/package-summary#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)` does not use custom NavTypes. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.createGraph

Artifact: [androidx.navigation:navigation-dynamic-features-runtime](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/dynamicfeatures/NavController.kt+function:createGraph)

```
public final @NonNull NavGraph NavControllerKt.createGraph(
    @NonNull NavController receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull DynamicNavGraphBuilder, Unit> builder
)
```

Construct a new `https://developer.android.com/reference/androidx/navigation/NavGraph` that supports dynamic navigation destinations

| Parameters |
|---|---|
| `@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 ?> startDestination` | the starting destination's route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` for this NavGraph. The respective NavDestination must be added as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` in order to match. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> route` | the graph's unique route from a `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/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-type/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> typeMap` | A mapping of KType to custom NavType\<\*\> in the `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/package-summary#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)`. May be empty if `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/package-summary#(androidx.navigation.NavController).createGraph(kotlin.reflect.KClass,kotlin.reflect.KClass,kotlin.collections.Map,kotlin.Function1)` does not use custom NavTypes. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> builder` | the builder used to construct the graph |

### NavControllerKt.navigateUp

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/NavController.kt+function:navigateUp)

```
public final boolean NavControllerKt.navigateUp(
    @NonNull NavController receiver,
    @NonNull AppBarConfiguration appBarConfiguration
)
```

Handles the Up button by delegating its behavior to the given `https://developer.android.com/reference/androidx/navigation/NavController`.

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate up. |

### NavControllerKt.navigateUp

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/NavController.kt+function:navigateUp)

```
public final boolean NavControllerKt.navigateUp(
    @NonNull NavController receiver,
    Openable drawerLayout
)
```

Handles the Up button by delegating its behavior to the given `https://developer.android.com/reference/androidx/navigation/NavController`.

This is equivalent to calling `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` if the `https://developer.android.com/reference/androidx/customview/widget/Openable` layout is null.

| Returns |
|---|---|
| `boolean` | True if the `https://developer.android.com/reference/androidx/navigation/NavController` was able to navigate up. |