android / architecture-components-samples

Samples for Android Architecture Components.
https://d.android.com/arch
Apache License 2.0
23.4k stars 8.29k forks source link

navigating using Deeplink not work in NavigationAdvancedSample sample #1002

Open makazemi opened 3 years ago

makazemi commented 3 years ago

version navigation component: 2.4.0-alpha02 I try to use deeplink to navigate to UserProfile fragment. But the app crashed and this is the stack trace logcat.

Navigation destination that matches request NavDeepLinkRequest{ uri=www.example.com/user/person } cannot be found in the navigation graph NavGraph(com.example.android.navigationadvancedsample:id/nav_graph) startDestination={NavGraph(com.example.android.navigationadvancedsample:id/home) startDestination={Destination(com.example.android.navigationadvancedsample:id/titleScreen) label=Home class=com.example.android.navigationadvancedsample.homescreen.Title}} this is my code: holder.item.findNavController().navigate(Uri.parse("www.example.com/user/${ myDataset[position]}"))

Drjacky commented 2 years ago
val encodedUrl = URLEncoder.encode("www.example.com/user/${ myDataset[position]}", StandardCharsets.UTF_8.toString())
holder.item.findNavController().navigate("rootPathBlah/$encodedUrl")