Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

NavAction

public class NavAction
extends Object

java.lang.Object
   ↳ androidx.navigation.NavAction


Navigation actions provide a level of indirection between your navigation code and the underlying destinations. This allows you to define common actions that change their destination or NavOptions based on the current NavDestination.

The NavOptions associated with a NavAction are used by default when navigating to this action via NavController.navigate(int) or NavController.navigate(int, Bundle).

Actions should be added via NavDestination.putAction(int, int) or NavDestination.putAction(int, NavAction).

Summary

Public constructors

NavAction(int destinationId)

Creates a new NavAction for the given destination.

NavAction(int destinationId, NavOptions navOptions)

Creates a new NavAction for the given destination.

Public methods

int getDestinationId()

Gets the ID of the destination that should be navigated to when this action is used

NavOptions getNavOptions()

Gets the NavOptions to be used by default when navigating to this action.

void setNavOptions(NavOptions navOptions)

Sets the NavOptions to be used by default when navigating to this action.

Inherited methods

Public constructors

public NavAction (int destinationId)

Creates a new NavAction for the given destination.

Parameters
destinationId int: the ID of the destination that should be navigated to when this action is used.

public NavAction (int destinationId, 
                NavOptions navOptions)

Creates a new NavAction for the given destination.

Parameters
destinationId int: the ID of the destination that should be navigated to when this action is used.

navOptions NavOptions: special options for this action that should be used by default

Public methods

getDestinationId

public int getDestinationId ()

Gets the ID of the destination that should be navigated to when this action is used

Returns
int

getNavOptions

public NavOptions getNavOptions ()

Gets the NavOptions to be used by default when navigating to this action.

Returns
NavOptions

setNavOptions

public void setNavOptions (NavOptions navOptions)

Sets the NavOptions to be used by default when navigating to this action.

Parameters
navOptions NavOptions: special options for this action that should be used by default