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 |
Public constructors |
|
|---|---|
NavBackStackEntry( |
|
Public methods |
|
|---|---|
boolean |
|
@NonNull ViewModelProvider.Factory |
Returns the default |
@NonNull Lifecycle |
{@inheritDoc} |
@NonNull SavedStateRegistry |
Returns owned |
@NonNull ViewModelStore |
{@inheritDoc} |
int |
hashCode() |
Public fields
destination
@NonNull
public final @NonNull NavDestination destination
The destination associated with this entry
| Returns | |
|---|---|
@NonNull NavDestination |
The destination that is currently visible to users |
savedStateHandle
@NonNull
public final @NonNull SavedStateHandle savedStateHandle
The SavedStateHandle for this entry.
Public constructors
NavBackStackEntry
@RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP])
public final NavBackStackEntry(
@NonNull NavBackStackEntry entry,
@Nullable Bundle arguments
)
Public methods
getDefaultViewModelProviderFactory
@NonNull
public ViewModelProvider.Factory getDefaultViewModelProviderFactory()
Returns the default androidx.lifecycle.ViewModelProvider.Factory that should be used when no custom {@code Factory} is provided to the androidx.lifecycle.ViewModelProvider constructors.
| Returns | |
|---|---|
ViewModelProvider.Factory |
a |
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.
getSavedStateRegistry
@NonNull
public SavedStateRegistry getSavedStateRegistry()
Returns owned SavedStateRegistry
| Returns | |
|---|---|
SavedStateRegistry |
|
getViewModelStore
@NonNull
public ViewModelStore getViewModelStore()
{@inheritDoc}
| Throws | |
|---|---|
kotlin.IllegalStateException |
if called before the |