androidandroid-activityintentfilter

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)


Solution

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