NavDeepLinkBuilder
public
final
class
NavDeepLinkBuilder
extends Object
java.lang.Object | |
↳ | androidx.navigation.NavDeepLinkBuilder |
Class used to construct deep links to a particular destination in a NavGraph
.
When this deep link is triggered:
- The task is cleared.
- The destination and all of its parents will be on the back stack.
- Calling
NavController.navigateUp()
will navigate to the parent of the destination.
start destination
of the containing navigation graph
. In the cases where the destination is
the start destination of its containing navigation graph, the start destination of its
grandparent is used.
You can construct an instance directly with NavDeepLinkBuilder(Context)
or build one
using an existing NavController
via NavController.createDeepLink()
.
Summary
Public constructors | |
---|---|
NavDeepLinkBuilder(Context context)
Construct a new NavDeepLinkBuilder. |
Public methods | |
---|---|
PendingIntent
|
createPendingIntent()
Construct a |
TaskStackBuilder
|
createTaskStackBuilder()
Construct the full |
NavDeepLinkBuilder
|
setArguments(Bundle args)
Set optional arguments to send onto the destination |
NavDeepLinkBuilder
|
setComponentName(Class<? extends Activity> activityClass)
Sets an explicit Activity to be started by the deep link created by this class. |
NavDeepLinkBuilder
|
setComponentName(ComponentName componentName)
Sets an explicit Activity to be started by the deep link created by this class. |
NavDeepLinkBuilder
|
setDestination(int destId)
Sets the destination id to deep link to. |
NavDeepLinkBuilder
|
setGraph(int navGraphId)
Sets the graph that contains the |
NavDeepLinkBuilder
|
setGraph(NavGraph navGraph)
Sets the graph that contains the |
Inherited methods | |
---|---|
Public constructors
NavDeepLinkBuilder
public NavDeepLinkBuilder (Context context)
Construct a new NavDeepLinkBuilder.
If the context passed in here is not an Activity
, this method will use
PackageManager.getLaunchIntentForPackage(String)
as the
default activity to launch, if available.
Parameters | |
---|---|
context |
Context : Context used to create deep links |
See also:
Public methods
createPendingIntent
public PendingIntent createPendingIntent ()
Construct a PendingIntent
to the deep link destination
.
This constructs the entire task stack
needed.
You must have set a NavGraph
and set a destination
before calling this method.
Returns | |
---|---|
PendingIntent |
a PendingIntent constructed with
TaskStackBuilder.getPendingIntent(int, int) to deep link to the
given destination
|
createTaskStackBuilder
public TaskStackBuilder createTaskStackBuilder ()
Construct the full task stack
needed to deep link to the given
destination.
You must have set a NavGraph
and set a destination
before calling this method.
Returns | |
---|---|
TaskStackBuilder |
a TaskStackBuilder which can be used to
send the deep link or
create a PendingIntent to deep link to
the given destination.
|
setArguments
public NavDeepLinkBuilder setArguments (Bundle args)
Set optional arguments to send onto the destination
Parameters | |
---|---|
args |
Bundle : arguments to pass to the destination |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |
setComponentName
public NavDeepLinkBuilder setComponentName (Class<? extends Activity> activityClass)
Sets an explicit Activity to be started by the deep link created by this class.
Parameters | |
---|---|
activityClass |
Class : The Activity to start. This Activity should have a NavController
which uses the same NavGraph used to construct this
deep link. |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |
setComponentName
public NavDeepLinkBuilder setComponentName (ComponentName componentName)
Sets an explicit Activity to be started by the deep link created by this class.
Parameters | |
---|---|
componentName |
ComponentName : The Activity to start. This Activity should have a NavController
which uses the same NavGraph used to construct this
deep link. |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |
setDestination
public NavDeepLinkBuilder setDestination (int destId)
Sets the destination id to deep link to.
Parameters | |
---|---|
destId |
int : destination ID to deep link to. |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |
setGraph
public NavDeepLinkBuilder setGraph (int navGraphId)
Sets the graph that contains the deep link destination
.
Parameters | |
---|---|
navGraphId |
int : ID of the NavGraph containing the deep link destination |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |
setGraph
public NavDeepLinkBuilder setGraph (NavGraph navGraph)
Sets the graph that contains the deep link destination
.
If you do not have access to a NavController
, you can create a
NavigatorProvider
and use that to programmatically construct a navigation
graph or use NavInflater
.
Parameters | |
---|---|
navGraph |
NavGraph : The NavGraph containing the deep link destination |
Returns | |
---|---|
NavDeepLinkBuilder |
this object for chaining |