是否可以在深层链接 URI 中使用字符串常量?
目前我有几个链接,导致host部分重复:
<deepLink app:uri="www.host.com/a" />
<deepLink app:uri="www.host.com/b" />
<deepLink app:uri="www.host.com/c" />
<deepLink app:uri="www.host.com/d" />
因此,我正在寻找一种以某种方式提取 www.host.com
的方法。
我一直天真地尝试将它提取到 strings.xml
:
<string name="host">www.host.com</string>
然后:
<deepLink app:uri="{@string/host}/details/{id}" />
但这不起作用(在深度链接 URI 主机中不正确使用通配符和/或占位符
编译错误)
最佳答案
如对此问题的评论中所述 OP想在深层链接 uri 中使用常量字符串进行多次使用。名为 Entity declaration 的 XML 功能允许这样做。
也回答了具有类似目标的问题here .
关于android - 使用 Jetpack Navigation 在深度链接 URI 中使用字符串常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63244073/