如果提供的参数包含特殊字符,则无法在 Jetpack Compose 中导航

Ali*_*ris 4 android android-jetpack-navigation android-jetpack-compose

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
Run Code Online (Sandbox Code Playgroud)

在哪里

我可以更改此设置(PIN 码/密码)吗?

是我的屏幕的标题。我在尝试导航时遇到异常。我怎样才能避免这个问题,因为我的标题包含“/”,它被视为深层链接本身的一部分。

Dr.*_*dRO 6

撰写中基于 url 的导航不支持特殊字符。

如果您觉得字符串参数中有特殊字符。您可以尝试将其编码为java.util.Base64

val titleArg = Base64.getUrlEncoder().encodeToString(title.toByteArray())
Run Code Online (Sandbox Code Playgroud)

然后将其titleArg作为导航参数或路径发送

接收时只需进行这样的解码

val title = String(Base64.getUrlDecoder().decode(titleArg))
Run Code Online (Sandbox Code Playgroud)