Android 12 Developer Preview is here! Try it out, and give us your feedback!

Global actions

You can use a global action to create a common action that multiple destinations can use. For example, you might want buttons in different destinations to navigate to the same main app screen.

A global action is represented in the Navigation Editor by a small arrow that points to the associated destination, as shown in figure 1.

Figure 1. A global action that leads to a nested graph.

Create a global action

To create a global action, do the following:

  1. From the Graph Editor, click on a destination to highlight it.
  2. Right-click on the destination to display the context menu.
  3. Select Add Action > Global. An arrow () appears to the left of the destination.
  4. Click the Text tab to navigate to the XML text view. The XML for the global action looks similar to the following:

    <?xml version="1.0" encoding="utf-8"?>
    <navigation xmlns:app=""
      <action android:id="@+id/action_global_mainFragment"

Use a global action

To use a global action in your code, pass the resource ID of the global action to the navigate() method for each UI element, as shown in the following example:


viewTransactionButton.setOnClickListener { view ->


viewTransactionsButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View view) {

Use Safe Args with a global action

For information on using Safe Args with global actions, see Pass data between destinations.

Additional resources

To learn more about navigation, consult the following additional resources.