The Android Developer Challenge is back! Submit your idea before December 2.

Destination

open class Destination : NavDestination
kotlin.Any
   ↳ androidx.navigation.NavDestination
   ↳ androidx.navigation.ActivityNavigator.Destination

NavDestination for activity navigation

Summary

Public constructors

<init>(@NonNull navigatorProvider: NavigatorProvider)

Construct a new activity destination.

<init>(@NonNull activityNavigator: Navigator<out ActivityNavigator.Destination!>)

Construct a new activity destination.

Public methods

String?

Get the action used to start the Activity, if any

ComponentName?

Get the explicit ComponentName associated with this destination, if any

Uri?

Get the data URI used to start the Activity, if any

String?

Gets the dynamic data URI pattern, if any

Intent?

Gets the Intent associated with this destination.

String?

Get the explicit application package name associated with this destination, if any

open Unit
onInflate(@NonNull context: Context, @NonNull attrs: AttributeSet)

ActivityNavigator.Destination
setAction(@Nullable action: String?)

Sets the action sent when navigating to this destination.

ActivityNavigator.Destination
setComponentName(@Nullable name: ComponentName?)

Set an explicit ComponentName to navigate to.

ActivityNavigator.Destination
setData(@Nullable data: Uri?)

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

ActivityNavigator.Destination
setDataPattern(@Nullable dataPattern: String?)

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

ActivityNavigator.Destination
setIntent(@Nullable intent: Intent?)

Set the Intent to start when navigating to this destination.

ActivityNavigator.Destination
setTargetPackage(@Nullable packageName: String?)

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

open String

Inherited functions

Public constructors

<init>

Destination(@NonNull navigatorProvider: NavigatorProvider)

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

Parameters
navigatorProvider NavigatorProvider: The NavController which this destination will be associated with.

<init>

Destination(@NonNull activityNavigator: Navigator<out ActivityNavigator.Destination!>)

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

Parameters
activityNavigator Navigator<out ActivityNavigator.Destination!>: The ActivityNavigator which this destination will be associated with. Generally retrieved via a NavController's NavigatorProvider#getNavigator(Class) method.

Public methods

getAction

@Nullable fun getAction(): String?

Get the action used to start the Activity, if any

getComponent

@Nullable fun getComponent(): ComponentName?

Get the explicit ComponentName associated with this destination, if any

Return
ComponentName?:

getData

@Nullable fun getData(): Uri?

Get the data URI used to start the Activity, if any

getDataPattern

@Nullable fun getDataPattern(): String?

Gets the dynamic data URI pattern, if any

getIntent

@Nullable fun getIntent(): Intent?

Gets the Intent associated with this destination.

Return
Intent?:

getTargetPackage

@Nullable fun getTargetPackage(): String?

Get the explicit application package name associated with this destination, if any

onInflate

@CallSuper open fun onInflate(@NonNull context: Context, @NonNull attrs: AttributeSet): Unit

setAction

@NonNull fun setAction(@Nullable action: String?): ActivityNavigator.Destination

Sets the action sent when navigating to this destination.

Parameters
action String?: The action string to use.
Return
ActivityNavigator.Destination: this Destination

setComponentName

@NonNull fun setComponentName(@Nullable name: ComponentName?): ActivityNavigator.Destination

Set an explicit ComponentName to navigate to.

Parameters
name ComponentName?: The component name of the Activity to start.
Return
ActivityNavigator.Destination: this Destination

setData

@NonNull fun setData(@Nullable data: Uri?): ActivityNavigator.Destination

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(String), which will take precedence when arguments are present.

Parameters
data Uri?: A static URI that should always be used.
Return
ActivityNavigator.Destination: this Destination

setDataPattern

@NonNull fun setDataPattern(@Nullable dataPattern: String?): ActivityNavigator.Destination

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
dataPattern String?: 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.
Return
ActivityNavigator.Destination: this Destination

See Also

setIntent

@NonNull fun setIntent(@Nullable intent: Intent?): ActivityNavigator.Destination

Set the Intent to start when navigating to this destination.

Parameters
intent Intent?: Intent to associated with this destination.
Return
ActivityNavigator.Destination: this Destination

setTargetPackage

@NonNull fun setTargetPackage(@Nullable packageName: String?): ActivityNavigator.Destination

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
packageName String?: packageName to set
Return
ActivityNavigator.Destination: this Destination

toString

@NonNull open fun toString(): String