Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

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 Navigator to enable Navigator specific behavior.

This annotation should be added to each Navigator subclass to denote the default name used to register the Navigator with a NavigatorProvider.

Public constructors

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 destination: D, @Nullable args: Bundle?, @Nullable navOptions: NavOptions?, @Nullable navigatorExtras: Navigator.Extras?)

Navigate to a destination.

open Unit
onRestoreState(@NonNull savedState: Bundle)

Restore any state previously saved in onSaveState().

open Bundle?

Called to ask for a Bundle representing the Navigator's state.

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
@Nullable abstract fun navigate(
    @NonNull destination: D,
    @Nullable args: Bundle?,
    @Nullable navOptions: NavOptions?,
    @Nullable navigatorExtras: Navigator.Extras?
): NavDestination?

Navigate to a destination.

Requests navigation to a given destination associated with this navigator in the navigation graph. This method generally should not be called directly; NavController will delegate to it when appropriate.

Parameters
destination