意图过滤器路径preFIX以'#'不工作 [英] 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)
推荐答案
意图过滤器使用 UriMatcher 解析的URI,并确定是否存在匹配。 #
是URI通配符一个数字作为中的 UriMatcher 。按照<一href="https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/content/UriMatcher.java">UriMatcher来源$ C $ C ,没有转义序列逃脱#
的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).
这篇关于意图过滤器路径preFIX以'#'不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!