NavBackStackEntry

public final class NavBackStackEntry implements LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, SavedStateRegistryOwner


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 methods

boolean
equals(Object other)
final Bundle

The arguments used for this entry.

@NonNull CreationExtras

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

@NonNull ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

final @NonNull NavDestination

The destination associated with this entry

final @NonNull String

The unique ID that serves as the identity of this entry

@NonNull Lifecycle

Returns the Lifecycle of the provider.

final @NonNull SavedStateHandle

The SavedStateHandle for this entry.

@NonNull SavedStateRegistry

The SavedStateRegistry owned by this SavedStateRegistryOwner

@NonNull ViewModelStore

{@inheritDoc}

int
@NonNull String

Public methods

equals

public boolean equals(Object other)

getArguments

Added in 2.2.0
public final Bundle getArguments()

The arguments used for this entry. Note that the arguments of a NavBackStackEntry are immutable and defined when you navigate() to the destination - changes you make to this Bundle will not be reflected in future calls to this property.

Returns
Bundle

The arguments used when this entry was created

getDefaultViewModelCreationExtras

public @NonNull CreationExtras getDefaultViewModelCreationExtras()

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

getDefaultViewModelProviderFactory

Added in 2.2.0
public @NonNull ViewModelProvider.Factory getDefaultViewModelProviderFactory()

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

getDestination

Added in 2.2.0
public final @NonNull NavDestination getDestination()

The destination associated with this entry

Returns
@NonNull NavDestination

The destination that is currently visible to users

getId

public final @NonNull String getId()

The unique ID that serves as the identity of this entry

Returns
@NonNull String

the unique ID of this entry

getLifecycle

Added in 2.2.0
public @NonNull Lifecycle getLifecycle()

Returns the Lifecycle of the provider.

Returns
@NonNull Lifecycle

The lifecycle of the provider.

getSavedStateHandle

Added in 2.3.0
@MainThread
public final @NonNull SavedStateHandle getSavedStateHandle()

The SavedStateHandle for this entry.

getSavedStateRegistry

Added in 2.2.0
public @NonNull SavedStateRegistry getSavedStateRegistry()

The SavedStateRegistry owned by this SavedStateRegistryOwner

getViewModelStore

Added in 2.2.0
public @NonNull ViewModelStore getViewModelStore()

{@inheritDoc}

hashCode

public int hashCode()

toString

public @NonNull String toString()