Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

NavOptions

public class NavOptions
extends Object

java.lang.Object
   ↳ androidx.navigation.NavOptions


NavOptions stores special options for navigate actions

Summary

Nested classes

class NavOptions.Builder

Builder for constructing new instances of NavOptions. 

Public methods

static void addPopAnimationsToIntent(Intent intent, NavOptions navOptions)

Add the pop enter and pop exit animation to an Intent for later usage with applyPopAnimationsToPendingTransition(Activity).

static void applyPopAnimationsToPendingTransition(Activity activity)

Apply any pop animations in the Intent of the given Activity to a pending transition.

int getEnterAnim()

The custom enter Animation/Animator that should be run.

int getExitAnim()

The custom exit Animation/Animator that should be run.

int getPopEnterAnim()

The custom enter Animation/Animator that should be run when this destination is popped from the back stack.

int getPopExitAnim()

The custom exit Animation/Animator that should be run when this destination is popped from the back stack.

int getPopUpTo()

The destination to pop up to before navigating.

boolean isPopUpToInclusive()

Whether the destination set in getPopUpTo() should be popped from the back stack.

boolean shouldClearTask()

This method is deprecated. This is synonymous with getPopUpTo() with the root of the graph and using isPopUpToInclusive().

boolean shouldLaunchDocument()

This method is deprecated. As per the Intent.FLAG_ACTIVITY_NEW_DOCUMENT documentation, it is recommended to use R.attr.documentLaunchMode on an Activity you wish to launch as a new document.

boolean shouldLaunchSingleTop()

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

Inherited methods

Public methods

addPopAnimationsToIntent

public static void addPopAnimationsToIntent (Intent intent, 
                NavOptions navOptions)

Add the pop enter and pop exit animation to an Intent for later usage with applyPopAnimationsToPendingTransition(Activity).

This is automatically called for you by ActivityNavigator.

Parameters
intent Intent: Intent being started with the given NavOptions

navOptions NavOptions: NavOptions containing the pop animations.

applyPopAnimationsToPendingTransition

public static void applyPopAnimationsToPendingTransition (Activity activity)

Apply any pop animations in the Intent of the given Activity to a pending transition. This should be used in place of Activity.overridePendingTransition(int, int) to get the appropriate pop animations.

Parameters
activity Activity: An activity started from the ActivityNavigator.

getEnterAnim

public int getEnterAnim ()

The custom enter Animation/Animator that should be run.

Returns
int the resource id of a Animation or Animator or -1 if none.

getExitAnim

public int getExitAnim ()

The custom exit Animation/Animator that should be run.

Returns
int the resource id of a Animation or Animator or -1 if none.

getPopEnterAnim

public int getPopEnterAnim ()

The custom enter Animation/Animator that should be run when this destination is popped from the back stack.

Returns
int the resource id of a Animation or Animator or -1 if none.

getPopExitAnim

public int getPopExitAnim ()

The custom exit Animation/Animator that should be run when this destination is popped from the back stack.

Returns
int the resource id of a Animation or Animator or -1 if none.

getPopUpTo

public int getPopUpTo ()

The destination to pop up to before navigating. When set, all non-matching destinations should be popped from the back stack.

Returns
int the destinationId to pop up to, clearing all intervening destinations

isPopUpToInclusive

public boolean isPopUpToInclusive ()

Whether the destination set in getPopUpTo() should be popped from the back stack.

Returns
boolean

shouldClearTask

public boolean shouldClearTask ()

This method is deprecated.
This is synonymous with getPopUpTo() with the root of the graph and using isPopUpToInclusive().

Whether this navigation action should clear the entire back stack

This functions similarly to how Intent.FLAG_ACTIVITY_CLEAR_TASK works with activites.

Returns
boolean

shouldLaunchDocument

public boolean shouldLaunchDocument ()

This method is deprecated.
As per the Intent.FLAG_ACTIVITY_NEW_DOCUMENT documentation, it is recommended to use R.attr.documentLaunchMode on an Activity you wish to launch as a new document.

Whether this navigation action should launch the destination in a new document.

This functions similarly to how Intent.FLAG_ACTIVITY_NEW_DOCUMENT works with activites.

Returns
boolean

shouldLaunchSingleTop

public boolean shouldLaunchSingleTop ()

Whether this navigation action should launch as single-top (i.e., there will be at most one copy of a given destination on the top of the back stack).

This functions similarly to how Intent.FLAG_ACTIVITY_SINGLE_TOP works with activites.

Returns
boolean