NavBackStackEntry

public final class NavBackStackEntry implements LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, LifecycleOwner, 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 fields

final Bundle

The arguments used for this entry

final @NonNull NavDestination

The destination associated with this entry

final @NonNull String

The unique ID that serves as the identity of this entry

final @NonNull SavedStateHandle

The SavedStateHandle for this entry.

Public constructors

Public methods

boolean
equals(Object other)
@NonNull ViewModelProvider.Factory

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

@NonNull Lifecycle

{@inheritDoc}

@NonNull SavedStateRegistry

Returns owned SavedStateRegistry

@NonNull ViewModelStore

{@inheritDoc}

int

Public fields

arguments

public final Bundle arguments

The arguments used for this entry

Returns
Bundle

The arguments used when this entry was created

destination

public final @NonNull NavDestination destination

The destination associated with this entry

Returns
@NonNull NavDestination

The destination that is currently visible to users

id

public final @NonNull String id

The unique ID that serves as the identity of this entry

Returns
@NonNull String

the unique ID of this entry

savedStateHandle

public final @NonNull SavedStateHandle savedStateHandle

The SavedStateHandle for this entry.

Public constructors

@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
public final NavBackStackEntry(NavBackStackEntry entry, Bundle arguments)

Public methods

equals

public boolean equals(Object other)

getDefaultViewModelProviderFactory

public @NonNull ViewModelProvider.Factory getDefaultViewModelProviderFactory()

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

Returns
@NonNull ViewModelProvider.Factory

a ViewModelProvider.Factory

getLifecycle

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.

getViewModelStore

public @NonNull ViewModelStore getViewModelStore()

{@inheritDoc}

Throws
kotlin.IllegalStateException

if called before the <