Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
767 views
in Technique[技术] by (71.8m points)

android - Intent filter pathPrefix with '#' not working

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

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?

UPDATE: when I said "tried escaping" I meant using percent encoding (# equals %23)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...