Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter only specific URL with intent filter

I want to filter specific URL : http://gaapa.cz/mobile/*

But this filter is fired on every URl - ehta's wrong with that?

<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="gaapa.cz"
                android:path="/mobile/.*"
                android:scheme="http" />
</intent-filter>
like image 532
Hurda Avatar asked Mar 18 '12 18:03

Hurda


People also ask

Which components can you specify in an intent filter?

Each intent filter specifies the type of intents it accepts based on the intent's action, data, and category. The system delivers an implicit intent to your app component only if the intent can pass through one of your intent filters.

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

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.

What is category in intent filter?

Categories are used for implicit Intents. So, If your Activity can be started by an implicit Intent when no other specific category is assigned to activity, activity's Intent filter should include this category. (even if you have other categories in the Intent filter).


3 Answers

You want to either use path, pathPrefix, or pathPattern, according to the docs here.

In your case, either pathPattern or pathPrefix will work,

pathPattern="mobile/*"

or

pathPrefix="mobile"

However, that does not explain why your filter is matching all URIs. it should be matching none since path does not understand "*". i suspect there is something added / missing from somewhere else in your code.

like image 200
Jeffrey Blattman Avatar answered Oct 19 '22 17:10

Jeffrey Blattman


Try this:

<data android:host="gaapa.cz"
      android:pathprefix="mobile/"
      android:scheme="http" />
like image 32
Dheeraj Vepakomma Avatar answered Oct 19 '22 17:10

Dheeraj Vepakomma


This should work:

<data android:host="gaapa.cz"
      android:path="mobile"
      android:pathPattern="*"
      android:scheme="http" />
like image 44
Abhishek Chanda Avatar answered Oct 19 '22 17:10

Abhishek Chanda