带有“#"的意图过滤器路径前缀不起作用 [英] Intent filter pathPrefix with '#' not working
问题描述
我正在尝试设置一个意图过滤器以在用户单击以下 URI 时启动我的活动:example.com/pathA/pathB/#pathC/someGUID
I'm trying to set an intent filter to launch my activity when user clicks on the following URI: example.com/pathA/pathB/#pathC/someGUID
所以我在清单文件中添加了以下 XML:
so I've added the following XML to the manifest file:
<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>
我认为 '#' 字符把一切都搞砸了,但我试过逃避这个字符,但没有运气.有什么想法吗?
I'm thinking that the '#' char is messing everthing up but I've tried escaping this char with no luck. Any ideas?
更新:当我说尝试转义"时,我的意思是使用百分比编码(# 等于 %23)
UPDATE: when I said "tried escaping" I meant using percent encoding (# equals %23)
推荐答案
Intent 过滤器使用 UriMatcher 解析 URI 并确定是否存在匹配项.#
是数字的 URI 通配符,如 UriMatcher.根据 UriMatcher 源代码,没有转义序列来转义 URI 中的 #
.因此,您应该使用另一个非保留符号(请注意,*
也被保留为任何文本的通配符).
Intent filters use UriMatcher to parse URIs and determine if there is a match. #
is the URI wildcard for a number as seen in examples in UriMatcher. Per the UriMatcher source code, there is no escape sequence to escape a #
in a URI. Therefore you should use another, non-reserved symbol (note that *
is also reserved as the wildcard for any text).
这篇关于带有“#"的意图过滤器路径前缀不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!