Skip to content Skip to sidebar Skip to footer

Intent Filters And Android:pathpattern

In my application, I want to handle links that use the following pattern: scheme://host/folder1/folder2/folder3/folder4/article I got it to work temporarily, by using the followin

Solution 1:

You're close, but missing the final part. This should work for you:

android:pathPattern="/.*/.*/.*/.*/..*"

This will match any paths with four repeating /[anything] as well as enforce that you must have something after the final /.

Just as you asked:

Url I want to handle:

http://www.laprensa.com.ni/2013/05/10/vida/145996-lionel-richie-defiende-a

Url I don't want to handle

http://www.laprensa.com.ni/2013/05/10/vida/

Explanation

The . enforces a pattern of "one of any character". The .* enforces "any number (or none!) of any character".

Combining these two, ..* enforces "any number of any characters, but at least one must be provided"

Solution 2:

You should add exactly the android:pathPattern attribute to configuration you defined. As reported in Android documentation, android:pathPattern can contain following wildcards for building simplified regular expressions:

  • An asterisk ('*') matches a sequence of 0 to many occurrences of the immediately preceding character.
  • A period followed by an asterisk (".*") matches any sequence of 0 to many characters.

In your case:

<data android:scheme="http"
      android:host="www.laprensa.com.ni"
      android:pathPattern="/.*/.*/.*/.*/.*" />

Where each .* represent a folder name.

Post a Comment for "Intent Filters And Android:pathpattern"