NavGraph
open class NavGraph : NavDestination, MutableIterable<NavDestination!>
NavGraph is a collection of NavDestination
nodes fetchable by ID.
A NavGraph serves as a 'virtual' destination: while the NavGraph itself will not appear on the back stack, navigating to the NavGraph will cause the starting destination
to be added to the back stack.
Summary
Public constructors |
Construct a new NavGraph.
|
Public methods |
Unit |
Add all destinations from another collection to this one.
|
Unit |
Adds a destination to this NavGraph.
|
Unit |
Adds multiple destinations to this NavGraph.
|
Unit |
Adds multiple destinations to this NavGraph.
|
Unit |
Clear all destinations from this navigation graph.
|
NavDestination? |
Finds a destination in the collection by ID.
|
Int |
Returns the starting destination for this NavGraph.
|
MutableIterator<NavDestination!> |
|
open Unit |
|
Unit |
Remove a given destination from this NavGraph
|
Unit |
Sets the starting destination for this NavGraph.
|
open String |
|
Inherited functions |
From class NavDestination
Unit |
addArgument(@NonNull argumentName: String, @NonNull argument: NavArgument)
Sets an argument type for an argument name
|
Unit |
addDeepLink(@NonNull uriPattern: String)
Add a deep link to this destination. Matching Uris sent to NavController#handleDeepLink(Intent) or NavController#navigate(Uri) will trigger navigating to this destination.
In addition to a direct Uri match, the following features are supported:
- Uris without a scheme are assumed as http and https. For example,
www.example.com will match http://www.example.com and https://www.example.com .
- Placeholders in the form of
{placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4 .
- The
.* wildcard can be used to match 0 or more characters.
These Uris can be declared in your navigation XML files by adding one or more <deepLink app:uri="uriPattern" /> elements as a child to your destination.
Deep links added in navigation XML files will automatically replace instances of ${applicationId} with the applicationId of your app. Programmatically added deep links should use Context#getPackageName() directly when constructing the uriPattern.
|
Unit |
addDeepLink(@NonNull navDeepLink: NavDeepLink)
Add a deep link to this destination. Uris that match the given NavDeepLink uri sent to NavController#handleDeepLink(Intent) or NavController#navigate(NavDeepLinkRequest) will trigger navigating to this destination.
In addition to a direct Uri match, the following features are supported:
- Uris without a scheme are assumed as http and https. For example,
www.example.com will match http://www.example.com and https://www.example.com .
- Placeholders in the form of
{placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4 .
- The
.* wildcard can be used to match 0 or more characters.
These Uris can be declared in your navigation XML files by adding one or more <deepLink app:uri="uriPattern" /> elements as a child to your destination.
Custom actions and mimetypes are also supported by NavDeepLink and can be declared in your navigation XML files by adding <app:action="android.intent.action.SOME_ACTION" /> or <app:mimetype="type/subtype" /> as part of your deepLink declaration.
Deep link Uris, actions, and mimetypes added in navigation XML files will automatically replace instances of ${applicationId} with the applicationId of your app. Programmatically added deep links should use Context#getPackageName() directly when constructing the uriPattern.
When matching deep links for calls to
| |