Assign Implicit deeplink programmatically

Viewed 332

In order to add a deep link implicitly, the deep link has to be added to XML. If I want to check if the destination can handle a deep link or modify it in some way then one added in XML is prohibitive.

I can see there is an addDeepLink but I haven't found a great example of it. If the deep link is added programmatically then is the nav graph even aware of it.

1 Answers

If you have the target destination in your graph, that's enough find it in the graph and add suit deep-link.

findNavController().graph
      .findNode(R.id.my_destination)
      ?.addDeepLink("hello://world")

Related