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 constructors

Public methods

final String

Route for the destination to pop up to before navigating.

final KClass<@NonNull ?>

Route from a KClass for the destination to pop up to before navigating.

final Object

Route from an Object for the destination to pop up to before navigating.

final boolean

Whether the destination set in popUpToRoute should be popped from the back stack.

final void
setPopUpToRoute(String popUpToRoute)
final void
setPopUpToRouteClass(KClass<@NonNull ?> popUpToRouteClass)
final void
setPopUpToRouteObject(Object popUpToRouteObject)
final boolean

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

Whether the back stack and the state of all destinations between the current destination and popUpToRoute should be saved for later restoration via Builder.setRestoreState or the restoreState attribute using the same ID as popUpToRoute (note: this matching ID is true if isPopUpToInclusive is true.

final boolean

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

Public constructors

public NavOptions()

Public methods

getPopUpToRoute

Added in 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
String

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

getPopUpToRouteClass

Added in 2.8.0
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

getPopUpToRouteObject

Added in 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
Object

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

isPopUpToInclusive

Added in 1.0.0
public final boolean isPopUpToInclusive()

Whether the destination set in popUpToRoute should be popped from the back stack.

setPopUpToRoute

public final void setPopUpToRoute(String popUpToRoute)

setPopUpToRouteClass

public final void setPopUpToRouteClass(KClass<@NonNull ?> popUpToRouteClass)

setPopUpToRouteObject

public final void setPopUpToRouteObject(Object popUpToRouteObject)

shouldLaunchSingleTop

Added in 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
public final boolean shouldPopUpToSaveState()

Whether the back stack and the state of all destinations between the current destination and popUpToRoute should be saved for later restoration via Builder.setRestoreState or the restoreState attribute using the same ID as popUpToRoute (note: this matching ID is true if isPopUpToInclusive is true. If isPopUpToInclusive is false, this matching ID is the id of the last destination that is popped).

shouldRestoreState

Added in 2.4.0
public final boolean shouldRestoreState()

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