Stay organized with collections Save and categorize content based on your preferences.

NavGraphNavigator

@Navigator.Name(value = "navigation") public class NavGraphNavigator extends Navigator

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 constructors

Public methods

@NonNull NavGraph

Creates a new NavGraph associated with this navigator.

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

Inherited methods

From class androidx.navigation.Navigator
NavDestination
navigate(
    @NonNull NavGraph destination,
    Bundle args,
    NavOptions navOptions,
    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.

Bundle

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

boolean

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

void
popBackStack(@NonNull NavBackStackEntry popUpTo, boolean savedState)

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

Inherited fields

From class androidx.navigation.Navigator
final boolean

Whether this Navigator is actively being used by a NavController.

final @NonNull NavigatorState

The state of the Navigator is the communication conduit between the Navigator and the NavController that has called onAttach.

Public constructors

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

public @NonNull NavGraph createDestination()

Creates a new NavGraph associated with this navigator.

Returns
@NonNull NavGraph

The created NavGraph.

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

if given destination is not a child of the current navgraph