-
- All Implemented Interfaces:
-
android.os.Parcelable
@Stable() public final class NavController<T extends Object> implements Parcelable
A backstack controller which is used for all navigation.
Backstack modifications are done with setNewBackstack method. More specific operation such as navigate, pop, replaceLast and their variants are provided as extension methods.
Implements Parcelable interface, so it may be stored in SavedStateHandle or remembered with rememberSaveable. Use rememberNavController for the latter.
The type specified in the type parameter must comply with the next requirements:
It must be possible to write the instances of the type into Parcel. Which means it should be Parcelable, Serializable, or of any natively supported data type (e.g. primitive or string).
It must be Stable, Immutable, or string/primitive.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classNavController.CREATOR
-
Field Summary
Fields Modifier and Type Field Description private final <ERROR CLASS>backstack
-
Method Summary
Modifier and Type Method Description final <ERROR CLASS>getBackstack()final UnitsetNewBackstack(List<NavEntry<T>> entries, NavAction action)Creates and sets a new backstack filled with entries. StringtoString()UnitwriteToParcel(Parcel parcel, Integer flags)IntegerdescribeContents()-
-
Method Detail
-
getBackstack
final <ERROR CLASS> getBackstack()
-
setNewBackstack
@MainThread() final Unit setNewBackstack(List<NavEntry<T>> entries, NavAction action)
Creates and sets a new backstack filled with entries.
You should use existing entries from backstack to preserve their identities and associated components (lifecycles, saved states, view models). New entries can be created with navEntry method. Any new rearrangement, duplication and removal of existing entries is a valid change.
Use this method when none of the built-in extension methods (navigate, pop, replaceLast and their variations) suits your need.
This function does not guarantee thread-safety and is intended to be called only from the main thread.
- Parameters:
action- an optional parameter, used as a hint for AnimatedNavHost to select a transition animation.
-
writeToParcel
Unit writeToParcel(Parcel parcel, Integer flags)
-
describeContents
Integer describeContents()
-
-
-
-