NavBackStackEntry

public final class NavBackStackEntry


Representation of an entry in the back stack of a androidx.navigation.NavController. The Lifecycle, ViewModelStore, and SavedStateRegistry provided via this object are valid for the lifetime of this destination on the back stack: when this destination is popped off the back stack, the lifecycle will be destroyed, state will no longer be saved, and ViewModels will be cleared.

Summary

Public fields

final @Nullable Bundle

Gets the arguments used for this entry

final @NonNull NavDestination

Gets the destination associated with this entry

final @NonNull String

Gets the unique ID that serves as the identity of this entry

final @NonNull Lifecycle.State
final @NonNull SavedStateHandle

Gets the SavedStateHandle for this entry.

Public methods

@NonNull ViewModelProvider.Factory
@NonNull Lifecycle

{@inheritDoc}

@NonNull SavedStateRegistry
@NonNull ViewModelStore

{@inheritDoc}

final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void
final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void
final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void
saveState(@NonNull Bundle outBundle)
final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void

Update the state to be the lower of the two constraints:

Public fields

arguments

@Nullable
public final @Nullable Bundle arguments

Gets the arguments used for this entry

Returns
@Nullable Bundle

The arguments used when this entry was created

destination

@NonNull
public final @NonNull NavDestination destination

Gets the destination associated with this entry

Returns
@NonNull NavDestination

The destination that is currently visible to users

id

@NonNull
public final @NonNull String id

Gets the unique ID that serves as the identity of this entry

Returns
@NonNull String

the unique ID of this entry

maxLifecycle

@NonNull
public final @NonNull Lifecycle.State maxLifecycle

savedStateHandle

@NonNull
public final @NonNull SavedStateHandle savedStateHandle

Gets the SavedStateHandle for this entry.

Returns
@NonNull SavedStateHandle

the SavedStateHandle for this entry

Public methods

getDefaultViewModelProviderFactory

@NonNull
public @NonNull ViewModelProvider.Factory getDefaultViewModelProviderFactory()

getLifecycle

@NonNull
public @NonNull Lifecycle getLifecycle()

{@inheritDoc}

If the androidx.navigation.NavHost has not called androidx.navigation.NavHostController.setLifecycleOwner, the Lifecycle will be capped at Lifecycle.State.CREATED.

getSavedStateRegistry

@NonNull
public @NonNull SavedStateRegistry getSavedStateRegistry()

getViewModelStore

@NonNull
public @NonNull ViewModelStore getViewModelStore()

{@inheritDoc}

Throws
kotlin.IllegalStateException

if called before the lifecycle has moved to Lifecycle.State.CREATED or before the androidx.navigation.NavHost has called androidx.navigation.NavHostController.setViewModelStore.

handleLifecycleEvent

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
@NonNull
public final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void handleLifecycleEvent(@NonNull Lifecycle.Event event)

replaceArguments

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
@NonNull
public final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void replaceArguments(@Nullable Bundle newArgs)

saveState

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
@NonNull
public final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void saveState(@NonNull Bundle outBundle)

updateState

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
@NonNull
public final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull void updateState()

Update the state to be the lower of the two constraints: