Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent filter using path,pathPrefix, or pathPattern

My test uri string is

http://test.host.com/path/test.html?key1=val1&key2=val2

And I make intent-filter in manifest

A. scheme & host (It works but I do not want)

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data
        android:scheme="http"
        android:host="test.host.com"
    />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

B. A & path(pathPrefix, pathPattern) (Not worked)

    <data
        android:scheme="http"
        android:host="test.host.com"

        1. android:path="path/test.html" -> not worked (link to chrome broswer)
        2. android:path="path"           -> not worked (link to chrome broswer)
        3. android:pathPrefix="path"     -> not worked (link to chrome broswer)
        4. android:pathPattern="user/invite.*"  -> same (I do not know pattern)

    />

I want to start my app when only (path/test.html),

like image 473
ChangUZ Avatar asked Oct 16 '13 05:10

ChangUZ


People also ask

What is pathPattern?

The pathPattern attribute specifies a complete path that is matched against the complete path in the Intent object, but it can contain the following wildcards: An asterisk (' * ') matches a sequence of 0 to many occurrences of the immediately preceding character.

What is intent filters explain intent filters with example?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

What is intent filter priority?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.

Can an activity have multiple intent filters?

However, since a component can have multiple intent filters, an intent that does not pass through one of a component's filters might make it through on another. An <intent-filter> element in the manifest file lists actions as <action> subelements. For example: <intent-filter . . . >


2 Answers

You are missing the slash at the beginning. The following should work:

android:path="/path/test.html"

OR

android:pathPrefix="/path/test.html"
like image 190
David Wasser Avatar answered Oct 23 '22 11:10

David Wasser


If you need start your app only If for link /path/test.html Then Use android:path attribute in data tag only

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http"
        android:host="test.host.com"
        android:path="/path/test.html" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

As android:path attribute specifies a complete path that is matched against the complete path in an Intent object. But android:pathPrefix attribute specifies a partial path that is matched against only the initial part of the path in the Intent object.

So when use android:pathPrefix attribute not android:path attribute That mean your app may start for /path/test.html, /path/test.html?key1=value1,/path/test.html?key1=value1&key2=value2,etc

More Information about android doc for data tag into intent-filter

like image 31
ahmed hamdy Avatar answered Oct 23 '22 11:10

ahmed hamdy