Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/testScreen/Can I change this (Pin / Password)?/100/300 } cannot be found in the navigation graph
where
Can I change this (Pin / Password)?
is the title for my screen. I get an exception while trying to navigate. How can I avoid this issue as my title contains ' / ' which is getting considered as part of the deeplink itself.
Special characters are not supported in url based navigation in compose.
If you feel there is a special character in your string argument. You can try encoding it to java.util.Base64
val titleArg = Base64.getUrlEncoder().encodeToString(title.toByteArray())
And then send this titleArg
as a navigation argument or path
While receiving it just do a decode like this
val title = String(Base64.getUrlDecoder().decode(titleArg))
In general, using utf8 is better (instead of Base64).
Encoding the argument with
URLEncoder.encode(argument, "utf-8")
and later decoding it with
URLDecoder.decode(backStackEntry.arguments?.getString("argument") ?: "","utf-8")
was enough in my case. This also handles the new lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With