NavGraphNavigator

public class NavGraphNavigator
extends Navigator<NavGraph>

java.lang.Object
   ↳ androidx.navigation.Navigator<androidx.navigation.NavGraph>
     ↳ androidx.navigation.NavGraphNavigator


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

Summary

Inherited constants

Public constructors

NavGraphNavigator(Context context)

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

Public methods

NavGraph createDestination()

Creates a new NavGraph associated with this navigator.

void navigate(NavGraph destination, Bundle args, NavOptions navOptions)

Navigate to a destination.

boolean popBackStack()

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

Inherited methods

Public constructors

NavGraphNavigator

NavGraphNavigator (Context context)

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

Public methods

createDestination

NavGraph createDestination ()

Creates a new NavGraph associated with this navigator.

Returns
NavGraph a new NavDestination

navigate

void navigate (NavGraph destination, 
                Bundle args, 
                NavOptions navOptions)

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.

Implementations should dispatchOnNavigatorNavigated(int, int) to notify listeners of the resulting navigation destination.

Parameters
destination NavGraph: destination node to navigate to

args Bundle: arguments to use for navigation

navOptions NavOptions: additional options for navigation

popBackStack

boolean popBackStack ()

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

Implementations should dispatchOnNavigatorNavigated(int, int) to notify listeners of the resulting navigation destination and return true if navigation was successful. Implementations should return false if navigation could not be performed, for example if the navigator's back stack was empty.

Returns
boolean true if pop was successful