Search code examples
androidurlandroid-intentintentfilter

HTTP Url handling with IntentFilter


I've read some other questions about this thread, but no one answered to my question.

My situation is the following: the user cliks on a URL on whatever app (like Facebook, Gmail...), this URL contains http:\\www.italiansubs.net/forum/... and some other params. I want the app to handle that specific link, so, following some other questions on the site, I tried this:

<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="italiansubs.net" android:scheme="www" />
    <data android:host="italiansubs.net" android:scheme="http" />
</intent-filter>

but everytime I click on URL with that syntax, the Browser shows up and opens the link. I need to incercept that link, then let the app do some other operations, but my app doesn't show as possible pick.

How can I make this code work?

Thanks.


Solution

  • The host value is the full domain name as it appears in the URL. This may mean that you need a few <data> elements to handle all combinations of scheme (if links might use either http or https) and host (foo.com, www.foo.com, wow.subdomains.are.cool.foo.com, etc.).