Matching a url pattern in <intent-filter>

user291701 picture user291701 · Jan 21, 2011 · Viewed 21.7k times · Source

I'd like one of my activities to pick up a particular url. The pattern is:

http://www.example.com/abc123/foo/xyz789

The path components "abc123" and "xyz789" can be any sequence of alpha-numerics, length > 1.

Doing this in my manifest:

<activity>
  <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:scheme="http"
      android:host="example.com" 
      android:pathPattern="/.*/foo/.*" />

but it seems that any pattern from my domain is getting matched, ie:

myexample.com
myexample.com/whatever

both get matched. I guess maybe the .* operator is not working as I expect here? Any help would be great,

Thanks

http://developer.android.com/guide/topics/manifest/data-element.html

Answer

CronosNull picture CronosNull · Jun 4, 2013

I had the same problem today, my solution was:

   <data android:pathPattern="/remotes/..*/..*"/>

using (..*) as a replacement for (.+)

In the original question's case I guess that this can work:

<data
                android:host="example.com"
                android:pathPattern="..*/foo/..*"
                android:scheme="http"/>