# NavOptions

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

*** ** * ** ***


```
public final class NavOptions
```

<br />

*** ** * ** ***

NavOptions stores special options for navigate actions

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/navigation/NavOptions.Builder` Builder for constructing new instances of NavOptions. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getEnterAnim()()` The custom enter Animation/Animator that should be run. |
| `final @https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getExitAnim()()` The custom exit Animation/Animator that should be run. |
| `final @https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getPopEnterAnim()()` The custom enter Animation/Animator that should be run when this destination is popped from the back stack. |
| `final @https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getPopExitAnim()()` The custom exit Animation/Animator that should be run when this destination is popped from the back stack. |
| `final @https://developer.android.com/reference/androidx/annotation/IdRes int` | `[getPopUpTo](https://developer.android.com/reference/androidx/navigation/NavOptions#getPopUpTo())()` **This method is deprecated.** Use popUpToId instead. |
| `final @https://developer.android.com/reference/androidx/annotation/IdRes int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getPopUpToId()()` The destination to pop up to before navigating. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getPopUpToRoute()()` Route for the destination to pop up to before navigating. |
| `final 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/NavOptions#getPopUpToRouteClass()()` Route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` for the destination to pop up to before navigating. |
| `final https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/navigation/NavOptions#getPopUpToRouteObject()()` Route from an Object for the destination to pop up to before navigating. |
| `int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#hashCode()()` |
| `int` | `https://developer.android.com/reference/androidx/navigation/NavOptions#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()()` Whether the destination set in `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` should be popped from the back stack. |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()()` Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack). |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()()` Whether the back stack and the state of all destinations between the current destination and `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` 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 ID as `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` (note: this matching ID is true if `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` is true. |
| `final boolean` | `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldRestoreState()()` Whether this navigation action should restore any state previously saved by `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` or the `popUpToSaveState` attribute. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigation/NavOptions#toString()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigation/NavOptions#toString()()` |

## Public methods

### equals

```
public boolean equals(Object other)
```

### equals

```
public boolean equals(Object other)
```

### getEnterAnim

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

```
public final @AnimatorRes @AnimRes int getEnterAnim()
```

The custom enter Animation/Animator that should be run.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | the resource id of a Animation or Animator or -1 if none. |

### getExitAnim

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

```
public final @AnimatorRes @AnimRes int getExitAnim()
```

The custom exit Animation/Animator that should be run.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | the resource id of a Animation or Animator or -1 if none. |

### getPopEnterAnim

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

```
public final @AnimatorRes @AnimRes int getPopEnterAnim()
```

The custom enter Animation/Animator that should be run when this destination is popped from the back stack.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | the resource id of a Animation or Animator or -1 if none. |

### getPopExitAnim

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

```
public final @AnimatorRes @AnimRes int getPopExitAnim()
```

The custom exit Animation/Animator that should be run when this destination is popped from the back stack.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/AnimatorRes @https://developer.android.com/reference/androidx/annotation/AnimRes int` | the resource id of a Animation or Animator or -1 if none. |

### getPopUpTo

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

```
public final @IdRes int [getPopUpTo](https://developer.android.com/reference/androidx/navigation/NavOptions#getPopUpTo())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Use popUpToId instead, use this instead:
>
> ```
> popUpToId
> ```

The destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int` | the destinationId to pop up to, clearing all intervening destinations |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.Int,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()` |   |

### getPopUpToId

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

```
public final @IdRes int getPopUpToId()
```

The destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IdRes int` | the destinationId to pop up to, clearing all intervening destinations |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()` |   |

### getPopUpToRoute

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

```
public final String getPopUpToRoute()
```

Route for the destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | the destination route to pop up to, clearing all intervening destinations |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()` |   |

### getPopUpToRouteClass

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

```
public final KClass<@NonNull ?> getPopUpToRouteClass()
```

Route from a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html` for the destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?>` | the destination route to pop up to, clearing all intervening destinations |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()` |   |

### getPopUpToRouteObject

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

```
public final Object getPopUpToRouteObject()
```

Route from an Object for the destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` | the destination route to pop up to, clearing all intervening destinations |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldPopUpToSaveState()` |   |

### hashCode

```
public int hashCode()
```

### hashCode

```
public int hashCode()
```

### isPopUpToInclusive

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

```
public final boolean isPopUpToInclusive()
```

Whether the destination set in `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` should be popped from the back stack.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` |   |

### shouldLaunchSingleTop

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

```
public final boolean shouldLaunchSingleTop()
```

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

This functions similarly to how `android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP` works with activities.

### shouldPopUpToSaveState

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

```
public final boolean shouldPopUpToSaveState()
```

Whether the back stack and the state of all destinations between the current destination and `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` 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 ID as `https://developer.android.com/reference/androidx/navigation/NavOptions#popUpToRoute()` (note: this matching ID is true if `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` is true. If `https://developer.android.com/reference/androidx/navigation/NavOptions#isPopUpToInclusive()` is false, this matching ID is the id of the last destination that is popped).

### shouldRestoreState

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

```
public final boolean shouldRestoreState()
```

Whether this navigation action should restore any state previously saved by `https://developer.android.com/reference/androidx/navigation/NavOptions.Builder#setPopUpTo(kotlin.String,kotlin.Boolean,kotlin.Boolean)` or the `popUpToSaveState` attribute.

### toString

```
public @NonNull String toString()
```

### toString

```
public @NonNull String toString()
```