gpt4 book ai didi

android - 带有 '#' 的 Intent 过滤器 pathPrefix 不起作用

转载 作者:太空狗 更新时间:2023-10-29 14:54:59 26 4
gpt4 key购买 nike

我正在尝试设置一个 Intent 过滤器以在用户点击以下 URI 时启动我的 Activity :example.com/pathA/pathB/#pathC/someGUID

所以我在 list 文件中添加了以下 XML:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="example.com"
android:pathPrefix="/pathA/pathB/#pathC"
android:scheme="http" />
</intent-filter>

我在想 '#' 字符搞砸了,但我试过转义这个字符,但没有成功。有什么想法吗?

更新:当我说“尝试转义”时,我的意思是使用百分比编码(# 等于 %23)

最佳答案

Intent 过滤器使用 UriMatcher解析 URI 并确定是否匹配。 # 是数字的 URI 通配符,如 UriMatcher 中的示例所示.根据 UriMatcher source code , 没有转义序列来转义 URI 中的 #。因此,您应该使用另一个非保留符号(请注意,* 也被保留为任何文本的通配符)。

关于android - 带有 '#' 的 Intent 过滤器 pathPrefix 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32398334/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com