Navigator
abstract class Navigator<D : NavDestination!>
kotlin.Any | |
↳ | androidx.navigation.Navigator |
Navigator defines a mechanism for navigating within an app.
Each Navigator sets the policy for a specific type of navigation, e.g. ActivityNavigator
knows how to launch into destinations
backed by activities using startActivity
.
Navigators should be able to manage their own back stack when navigating between two destinations that belong to that navigator. The NavController
manages a back stack of navigators representing the current navigation stack across all navigators.
Each Navigator should add the Navigator.Name annotation
to their class. Any custom attributes used by the associated destination
subclass should have a name corresponding with the name of the Navigator, e.g., ActivityNavigator
uses <declare-styleable name="ActivityNavigator">
Summary
Nested classes | |
---|---|
abstract |
Interface indicating that this class should be passed to its respective |
This annotation should be added to each Navigator subclass to denote the default name used to register the Navigator with a |
Public constructors | |
---|---|
<init>() Navigator defines a mechanism for navigating within an app. |
Public methods | |
---|---|
abstract D |
Construct a new NavDestination associated with this Navigator. |
abstract NavDestination? |
navigate(@NonNull : D, @Nullable : Bundle?, @Nullable : NavOptions?, @Nullable : Navigator.Extras?) Navigate to a destination. |
open Unit |
onRestoreState(@NonNull : Bundle) Restore any state previously saved in |
open Bundle? |
Called to ask for a |
abstract Boolean |
Attempt to pop this navigator's back stack, performing the appropriate navigation. |
Public constructors
<init>
Navigator()
Navigator defines a mechanism for navigating within an app.
Each Navigator sets the policy for a specific type of navigation, e.g. ActivityNavigator
knows how to launch into destinations
backed by activities using startActivity
.
Navigators should be able to manage their own back stack when navigating between two destinations that belong to that navigator. The NavController
manages a back stack of navigators representing the current navigation stack across all navigators.
Each Navigator should add the Navigator.Name annotation
to their class. Any custom attributes used by the associated destination
subclass should have a name corresponding with the name of the Navigator, e.g., ActivityNavigator
uses <declare-styleable name="ActivityNavigator">
Public methods
createDestination
@NonNull abstract fun createDestination(): D
Construct a new NavDestination associated with this Navigator.
Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.
Return | |
---|---|
D |
a new NavDestination |
navigate
@Nullable abstract fun navigate(
@NonNull : D,
@Nullable : Bundle?,
@Nullable : NavOptions?,
@Nullable :