NavOptions.Builder



Builder for constructing new instances of NavOptions.

Summary

Public constructors

android

Public functions

NavOptions
Cmn
android
NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

Cmn
android
inline NavOptions.Builder
<T : Any> setPopUpTo(inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

Cmn
android
NavOptions.Builder
<T : Any> setPopUpTo(route: KClass<T>, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

Cmn
android
NavOptions.Builder
<T : Any> setPopUpTo(route: T, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

Cmn
android
NavOptions.Builder
setPopUpTo(route: String?, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

Cmn
android
NavOptions.Builder
setRestoreState(restoreState: Boolean)

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

Cmn
android

Public constructors

Builder

Builder()

Public functions

build

fun build(): NavOptions
Returns
NavOptions

a constructed NavOptions

setLaunchSingleTop

fun setLaunchSingleTop(singleTop: Boolean): NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

Parameters
singleTop: Boolean

true to launch as single-top

setPopUpTo

inline fun <T : Any> setPopUpTo(inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
<T : Any>

route from a KClass for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

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

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun <T : Any> setPopUpTo(
    route: KClass<T>,
    inclusive: Boolean,
    saveState: Boolean = false
): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: KClass<T>

from the KClass of the destination T to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

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

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun <T : Any> setPopUpTo(route: T, inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: T

route from an Object for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

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

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun setPopUpTo(route: String?, inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: String?

route for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

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

Returns
NavOptions.Builder

this Builder

setRestoreState

fun setRestoreState(restoreState: Boolean): NavOptions.Builder

Whether this navigation action should restore any state previously saved by setPopUpTo or the popUpToSaveState attribute. If no state was previously saved with the destination ID being navigated to, this has no effect.