navigation/runtime/src/main/java/androidx/navigation/NavController.java
@SuppressWarnings("deprecation")
    public void navigate(@IdRes int resId, @Nullable Bundle args, @Nullable NavOptions navOptions) {
        NavDestination currentNode = mBackStack.isEmpty() ? mGraph : mBackStack.peekLast();
        if (currentNode == null) {
            throw new IllegalStateException("no current navigation node");
        }
        @IdRes int destId = resId;
        final NavAction navAction = currentNode.getAction(resId);
        if (navAction != null) {
            if (navOptions == null) {
                navOptions = navAction.getNavOptions();
            }
            destId = navAction.getDestinationId();
        }
        if (destId == 0 && navOptions != null && navOptions.getPopUpTo() != 0) {
            popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
            return;
        }

        if (destId == 0) {
            throw new IllegalArgumentException("Destination id == 0 can only be used"
                    + " in conjunction with navOptions.popUpTo != 0");
        }

        NavDestination node = findDestination(destId);
        if (node == null) {
            final String dest = NavDestination.getDisplayName(mContext, destId);
            throw new IllegalArgumentException("navigation destination " + dest
                    + (navAction != null
                    ? " referenced from action " + NavDestination.getDisplayName(mContext, resId)
                    : "")
                    + " is unknown to this NavController");
        }
        if (navOptions != null) {
            if (navOptions.shouldClearTask()) {
                // Start with a clean slate
                popBackStack(mGraph.getId(), true);
            } else if (navOptions.getPopUpTo() != 0) {
                popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
            }
        }
        node.navigate(args, navOptions);
    }
/**
     * Navigate to a destination from the current navigation graph. This supports both navigating
     * via an {@link NavDestination#getAction(int) action} and directly navigating to a destination.
     *
     * @param resId an {@link NavDestination#getAction(int) action} id or a destination id to
     *              navigate to
     * @param args arguments to pass to the destination
     * @param navOptions special options for this navigation operation
     */
Navigate to a destination from the current navigation graph. This supports both navigating
via an  NavDestination#getAction(int) action and directly navigating to a destination.

@param resId an  NavDestination#getAction(int) action id or a destination id to
navigate to
@param args arguments to pass to the destination
@param navOptions special options for this navigation operation
Navigate to a destination from the current navigation graph . This supports both navigating via an NavDestination#getAction ( int ) action and directly navigating to a destination . @param resId an NavDestination#getAction ( int ) action id or a destination id to navigate to @param args arguments to pass to the destination @param navOptions special options for this navigation operation
@SuppressWarnings("deprecation")
    public void navigate(@IdRes int resId, @Nullable Bundle args, @Nullable NavOptions navOptions) {
        NavDestination currentNode = mBackStack.isEmpty() ? mGraph : mBackStack.peekLast();
        if (currentNode == null) {
            throw new IllegalStateException("no current navigation node");
        }
        @IdRes int destId = resId;
        final NavAction navAction = currentNode.getAction(resId);
        if (navAction != null) {
            if (navOptions == null) {
                navOptions = navAction.getNavOptions();
            }
            destId = navAction.getDestinationId();
        }
        if (destId == 0 && navOptions != null && navOptions.getPopUpTo() != 0) {
            popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
            return;
        }
        if (destId == 0) {
            throw new IllegalArgumentException("Destination id == 0 can only be used"
                    + " in conjunction with navOptions.popUpTo != 0");
        }
        NavDestination node = findDestination(destId);
        if (node == null) {
            final String dest = NavDestination.getDisplayName(mContext, destId);
            throw new IllegalArgumentException("navigation destination " + dest
                    + (navAction != null
                    ? " referenced from action " + NavDestination.getDisplayName(mContext, resId)
                    : "")
                    + " is unknown to this NavController");
        }
        if (navOptions != null) {
            if (navOptions.shouldClearTask()) {
                popBackStack(mGraph.getId(), true);
            } else if (navOptions.getPopUpTo() != 0) {
                popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
            }
        }
        node.navigate(args, navOptions);
    }
@ SuppressWarnings ( "deprecation" ) public void navigate ( @ IdRes int resId , @ Nullable Bundle args , @ Nullable NavOptions navOptions ) { NavDestination currentNode = mBackStack . isEmpty ( ) ? mGraph : mBackStack . peekLast ( ) ; if ( currentNode == null ) { throw new IllegalStateException ( "no current navigation node" ) ; } @ IdRes int destId = resId ; final NavAction navAction = currentNode . getAction ( resId ) ; if ( navAction != null ) { if ( navOptions == null ) { navOptions = navAction . getNavOptions ( ) ; } destId = navAction . getDestinationId ( ) ; } if ( destId == 0 && navOptions != null && navOptions . getPopUpTo ( ) != 0 ) { popBackStack ( navOptions . getPopUpTo ( ) , navOptions . isPopUpToInclusive ( ) ) ; return ; } if ( destId == 0 ) { throw new IllegalArgumentException ( "Destination id == 0 can only be used" + " in conjunction with navOptions.popUpTo != 0" ) ; } NavDestination node = findDestination ( destId ) ; if ( node == null ) { final String dest = NavDestination . getDisplayName ( mContext , destId ) ; throw new IllegalArgumentException ( "navigation destination " + dest + ( navAction != null ? " referenced from action " + NavDestination . getDisplayName ( mContext , resId ) : "" ) + " is unknown to this NavController" ) ; } if ( navOptions != null ) { if ( navOptions . shouldClearTask ( ) ) { popBackStack ( mGraph . getId ( ) , true ) ; } else if ( navOptions . getPopUpTo ( ) != 0 ) { popBackStack ( navOptions . getPopUpTo ( ) , navOptions . isPopUpToInclusive ( ) ) ; } } node . navigate ( args , navOptions ) ; }
Navigate to a destination from the current navigation graph.
Navigate to a destination from the current navigation graph .
// Start with a clean slate