NavGraphNavigator

public class NavGraphNavigator extends Navigator

Object
   ↳ Navigator
     ↳ NavGraphNavigator
Known direct subclasses
DynamicGraphNavigator

Navigator for graphs in dynamic feature modules.


A Navigator built specifically for NavGraph elements. Handles navigating to the correct destination when the NavGraph is the target of navigation actions.

Construct a Navigator capable of routing incoming navigation requests to the proper destination within a NavGraph.

Summary

Public fields

final boolean

Whether this Navigator is actively being used by a NavController.

Public constructors

Public methods

@NonNull NavGraph

Creates a new NavGraph associated with this navigator.

void
navigate(
    @NonNull List<@NonNull NavBackStackEntry> entries,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)

Inherited methods

From class Navigator
@Nullable NavDestination
navigate(
    @NonNull NavGraph destination,
    @Nullable Bundle args,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)

Navigate to a destination.

@CallSuper void

Indicator that this Navigator is actively being used by a NavController.

void

Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation.

void

Restore any state previously saved in onSaveState.

@Nullable Bundle

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

void
popBackStack(@NonNull NavBackStackEntry popUpTo, boolean savedState)

Attempt to pop this navigator's back stack, performing the appropriate navigation.

boolean

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Public fields

isAttached

@NonNull
public final boolean isAttached

Whether this Navigator is actively being used by a NavController.

This is set to true when onAttach is called.

Public constructors

@NonNull
public final NavGraphNavigator(@NonNull NavigatorProvider navigatorProvider)
Parameters
@NonNull NavigatorProvider navigatorProvider

NavigatorProvider used to retrieve the correct Navigator to navigate to the start destination

Public methods

createDestination

@NonNull
public NavGraph createDestination()

Creates a new NavGraph associated with this navigator.

Returns
NavGraph

The created NavGraph.

@NonNull
public void navigate(
    @NonNull List<@NonNull NavBackStackEntry> entries,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)
Throws
kotlin.IllegalArgumentException

if given destination is not a child of the current navgraph