ActivityNavigator.Destination

public class ActivityNavigator.Destination extends NavDestination


NavDestination for activity navigation

Construct a new activity destination. This destination is not valid until you set the Intent via setIntent or one or more of the other set method.

Summary

Public fields

final @Nullable String

The action used to start the Activity, if any

final @NonNull Map<@NonNull String, @NonNull NavArgument>

The arguments supported by this destination.

final @Nullable ComponentName

The explicit ComponentName associated with this destination, if any

final @Nullable Uri

The data URI used to start the Activity, if any

final @Nullable String

The dynamic data URI pattern, if any

final int

The destination's unique ID.

final @Nullable Intent

The Intent associated with this destination.

final @Nullable CharSequence

The descriptive label of this destination.

final @NonNull String

The name associated with this destination's Navigator.

final @Nullable NavGraph

Gets the NavGraph that contains this destination.

final @Nullable String

The destination's unique route.

final @Nullable String

The explicit application package name associated with this destination, if any

Public constructors

Construct a new activity destination.

Public methods

boolean
int
@CallSuper void

Called when inflating a destination from a resource.

final @NonNull ActivityNavigator.Destination

Sets the action sent when navigating to this destination.

final @NonNull ActivityNavigator.Destination

Set an explicit ComponentName to navigate to.

final @NonNull ActivityNavigator.Destination

Sets a static data URI that is sent when navigating to this destination.

final @NonNull ActivityNavigator.Destination

Sets a dynamic data URI pattern that is sent when navigating to this destination.

final @NonNull ActivityNavigator.Destination

Set the Intent to start when navigating to this destination.

final @NonNull ActivityNavigator.Destination

Set an explicit application package name that limits the components this destination will navigate to.

@NonNull String

Inherited methods

From class NavDestination
final void
addArgument(@NonNull String argumentName, @NonNull NavArgument argument)

Sets an argument type for an argument name

final void

Add a deep link to this destination.

final void
addDeepLink(@NonNull String uriPattern)

Add a deep link to this destination.

final @Nullable NavAction
getAction(@IdRes int id)

Returns the NavAction for the given action ID.

boolean
hasDeepLink(@NonNull Uri deepLink)

Checks the given deep link Uri, and determines whether it matches a Uri pattern added to the destination by a call to addDeepLink .

boolean

Checks the given NavDeepLinkRequest, and determines whether it matches a NavDeepLink added to the destination by a call to addDeepLink.

final void
putAction(@IdRes int actionId, @NonNull NavAction action)

Sets the NavAction destination for an action ID.

final void
putAction(@IdRes int actionId, @IdRes int destId)

Creates a NavAction for the given destId and associates it with the actionId.

final void
removeAction(@IdRes int actionId)

Unsets the NavAction for an action ID.

final void
removeArgument(@NonNull String argumentName)

Unsets the argument type for an argument name.

Public fields

action

@Nullable
public final @Nullable String action

The action used to start the Activity, if any

arguments

@NonNull
public final @NonNull Map<@NonNull String, @NonNull NavArgumentarguments

The arguments supported by this destination. Returns a read-only map of argument names to NavArgument objects that can be used to check the type, default value and nullability of the argument.

To add and remove arguments for this NavDestination use addArgument and removeArgument.

Returns
@NonNull Map<@NonNull String, @NonNull NavArgument>

Read-only map of argument names to arguments.

component

@Nullable
public final @Nullable ComponentName component

The explicit ComponentName associated with this destination, if any

data

@Nullable
public final @Nullable Uri data

The data URI used to start the Activity, if any

dataPattern

@Nullable
public final @Nullable String dataPattern

The dynamic data URI pattern, if any

id

@NonNull
public final int id

The destination's unique ID. This should be an ID resource generated by the Android resource system.

intent

@Nullable
public final @Nullable Intent intent

The Intent associated with this destination.

label

@Nullable
public final @Nullable CharSequence label

The descriptive label of this destination.

@NonNull
public final @NonNull String navigatorName

The name associated with this destination's Navigator.

parent

@Nullable
public final @Nullable NavGraph parent

Gets the NavGraph that contains this destination. This will be set when a destination is added to a NavGraph via NavGraph.addDestination.

route

@Nullable
public final @Nullable String route

The destination's unique route. Setting this will also update the id of the destinations so custom destination ids should only be set after setting the route.

Returns
@Nullable String

this destination's route, or null if no route is set

Throws
kotlin.IllegalArgumentException

is the given route is empty

targetPackage

@Nullable
public final @Nullable String targetPackage

The explicit application package name associated with this destination, if any

Public constructors

Destination

public final Destination(@NonNull NavigatorProvider navigatorProvider)

Construct a new activity destination. This destination is not valid until you set the Intent via setIntent or one or more of the other set method.

Parameters
@NonNull NavigatorProvider navigatorProvider

The NavController which this destination will be associated with.

Destination

public final Destination(
    @NonNull Navigator<@NonNull ActivityNavigator.Destination> activityNavigator
)
Parameters
@NonNull Navigator<@NonNull ActivityNavigator.Destination> activityNavigator

The ActivityNavigator which this destination will be associated with. Generally retrieved via a NavController's NavigatorProvider.getNavigator method.

Public methods

equals

@NonNull
public boolean equals(@Nullable Object other)

hashCode

@NonNull
public int hashCode()

onInflate

@CallSuper
@NonNull
public @CallSuper void onInflate(@NonNull Context context, @NonNull AttributeSet attrs)

Called when inflating a destination from a resource.

Parameters
@NonNull Context context

local context performing inflation

@NonNull AttributeSet attrs

attrs to parse during inflation

setAction

@NonNull
public final ActivityNavigator.Destination setAction(@Nullable String action)

Sets the action sent when navigating to this destination.

Parameters
@Nullable String action

The action string to use.

setComponentName

@NonNull
public final ActivityNavigator.Destination setComponentName(@Nullable ComponentName name)

Set an explicit ComponentName to navigate to.

Parameters
@Nullable ComponentName name

The component name of the Activity to start.

setData

@NonNull
public final ActivityNavigator.Destination setData(@Nullable Uri data)

Sets a static data URI that is sent when navigating to this destination.

To use a dynamic URI that changes based on the arguments passed in when navigating, use setDataPattern, which will take precedence when arguments are present.

Parameters
@Nullable Uri data

A static URI that should always be used.

See also
setDataPattern

setDataPattern

@NonNull
public final ActivityNavigator.Destination setDataPattern(@Nullable String dataPattern)

Sets a dynamic data URI pattern that is sent when navigating to this destination.

If a non-null arguments Bundle is present when navigating, any segments in the form {argName} will be replaced with a URI encoded string from the arguments.

Parameters
@Nullable String dataPattern

A URI pattern with segments in the form of {argName} that will be replaced with URI encoded versions of the Strings in the arguments Bundle.

See also
setData

setIntent

@NonNull
public final ActivityNavigator.Destination setIntent(@Nullable Intent intent)

Set the Intent to start when navigating to this destination.

Parameters
@Nullable Intent intent

Intent to associated with this destination.

setTargetPackage

@NonNull
public final ActivityNavigator.Destination setTargetPackage(@Nullable String packageName)

Set an explicit application package name that limits the components this destination will navigate to.

When inflated from XML, you can use ${applicationId} as the package name to automatically use Context.getPackageName.

Parameters
@Nullable String packageName

packageName to set

Returns