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 @Nullable 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

NavBackStackEntry(
    @NonNull NavBackStackEntry entry,
    @Nullable Bundle arguments
)

Public methods

boolean
@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

@Nullable
public final @Nullable Bundle arguments

The arguments used for this entry

Returns
@Nullable Bundle

The arguments used when this entry was created

destination

@NonNull
public final @NonNull NavDestination destination

The destination associated with this entry

Returns
@NonNull NavDestination

The destination that is currently visible to users

id

@NonNull
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

@NonNull
public final @NonNull SavedStateHandle savedStateHandle

The SavedStateHandle for this entry.

Public constructors

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

Public methods

equals

@NonNull
public boolean equals(@Nullable Object other)

getDefaultViewModelProviderFactory

@NonNull
public 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
ViewModelProvider.Factory

a ViewModelProvider.Factory

getLifecycle

@NonNull
public 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