NavBackStackEntry
class NavBackStackEntry : LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, SavedStateRegistryOwner
kotlin.Any | |
↳ | androidx.navigation.NavBackStackEntry |
Representation of an entry in the back stack of a 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 | |
---|---|
Bundle? |
Gets the arguments used for this entry |
ViewModelProvider.Factory | |
NavDestination |
Gets the destination associated with this entry |
Lifecycle |
Returns the Lifecycle of the provider. |
SavedStateHandle |
Gets the |
SavedStateRegistry | |
ViewModelStore |
Returns owned |
Public methods
getArguments
@Nullable fun getArguments(): Bundle?
Gets the arguments used for this entry
Return | |
---|---|
Bundle? |
The arguments used when this entry was created |
getDefaultViewModelProviderFactory
@NonNull fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory
getDestination
@NonNull fun getDestination(): NavDestination
Gets the destination associated with this entry
Return | |
---|---|
NavDestination |
The destination that is currently visible to users |
getLifecycle
@NonNull fun getLifecycle(): Lifecycle
Returns the Lifecycle of the provider.
If the NavHost
has not called NavHostController#setLifecycleOwner
, the Lifecycle will be capped at Lifecycle.State#CREATED
.
Return | |
---|---|
Lifecycle |
The lifecycle of the provider. |
getSavedStateHandle
@NonNull fun getSavedStateHandle(): SavedStateHandle
Gets the SavedStateHandle
for this entry.
Return | |
---|---|
SavedStateHandle |
the SavedStateHandle for this entry |
getSavedStateRegistry
@NonNull fun getSavedStateRegistry(): SavedStateRegistry
getViewModelStore
@NonNull fun getViewModelStore(): ViewModelStore
Returns owned ViewModelStore
Return | |
---|---|
ViewModelStore |
a ViewModelStore |
Exceptions | |
---|---|
IllegalStateException |
if called before the NavHost has called NavHostController#setViewModelStore . |