public final class NavOptions

NavOptions stores special options for navigate actions

Summary

Nested types

public final class NavOptions.Builder

Builder for constructing new instances of NavOptions.

Public methods

getPopEnterAnim

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
@AnimatorRes @AnimRes int

the resource id of a Animation or Animator or -1 if none.

getPopExitAnim

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
@AnimatorRes @AnimRes int

the resource id of a Animation or Animator or -1 if none.

public final @IdRes int getPopUpTo()

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

Returns
@IdRes int

the destinationId to pop up to, clearing all intervening destinations

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
@IdRes int

the destinationId to pop up to, clearing all intervening destinations

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
String

the destination route to pop up to, clearing all intervening destinations

public final KClass<@NonNull ?> getPopUpToRouteClass()

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

Returns
KClass<@NonNull ?>

the destination route to pop up to, clearing all intervening destinations

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
Object

the destination route to pop up to, clearing all intervening destinations

shouldLaunchSingleTop

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.

shouldRestoreState

public final boolean shouldRestoreState()

Whether this navigation action should restore any state previously saved by Builder.setPopUpTo or the popUpToSaveState attribute.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-05-15 UTC.