NavBackStackEntry
public
final
class
NavBackStackEntry
extends Object
implements
LifecycleOwner,
ViewModelStoreOwner,
HasDefaultViewModelProviderFactory,
SavedStateRegistryOwner
java.lang.Object | |
↳ | 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
|
getArguments()
Gets the arguments used for this entry |
ViewModelProvider.Factory
|
getDefaultViewModelProviderFactory()
Returns the default |
NavDestination
|
getDestination()
Gets the destination associated with this entry |
Lifecycle
|
getLifecycle()
Returns the Lifecycle of the provider.
If the |
SavedStateHandle
|
getSavedStateHandle()
Gets the |
SavedStateRegistry
|
getSavedStateRegistry()
Returns owned |
ViewModelStore
|
getViewModelStore()
Returns owned |
Inherited methods | |
---|---|
Public methods
getArguments
public Bundle getArguments ()
Gets the arguments used for this entry
Returns | |
---|---|
Bundle |
The arguments used when this entry was created |
getDefaultViewModelProviderFactory
public ViewModelProvider.Factory getDefaultViewModelProviderFactory ()
Returns the default ViewModelProvider.Factory
that should be
used when no custom Factory
is provided to the
ViewModelProvider
constructors.
Returns | |
---|---|
ViewModelProvider.Factory |
a ViewModelProvider.Factory
|
getDestination
public NavDestination getDestination ()
Gets the destination associated with this entry
Returns | |
---|---|
NavDestination |
The destination that is currently visible to users |
getLifecycle
public Lifecycle getLifecycle ()
Returns the Lifecycle of the provider.
If the NavHost
has not called NavHostController.setLifecycleOwner(LifecycleOwner)
, the
Lifecycle will be capped at Lifecycle.State.CREATED
.
Returns | |
---|---|
Lifecycle |
The lifecycle of the provider. |
getSavedStateHandle
public SavedStateHandle getSavedStateHandle ()
Gets the SavedStateHandle
for this entry.
Returns | |
---|---|
SavedStateHandle |
the SavedStateHandle for this entry |
getSavedStateRegistry
public SavedStateRegistry getSavedStateRegistry ()
Returns owned SavedStateRegistry
Returns | |
---|---|
SavedStateRegistry |
a SavedStateRegistry
|
getViewModelStore
public ViewModelStore getViewModelStore ()
Returns owned ViewModelStore
Returns | |
---|---|
ViewModelStore |
a ViewModelStore
|
Throws | |
---|---|
IllegalStateException |
if called before the NavHost has called
NavHostController.setViewModelStore(ViewModelStore) .
|