Hamid
Hamid

Reputation: 4440

http scheme intent filter for link to app from web

This seems to be a typical problem and there seems to be a lot of differing behaviour, the problem I'm having though is that my scheme will launch the picker and allow me to choose my app when I hit a link in an email or a note on the device, but if I hit a link on a web page I can't seem to launch the app, don't even get the picker (I'v checked the "defaults" for the two browsers and none are set).

<activity
                android:name=".MyActivity" 
                android:exported="true"
                android:enabled="true">
                <intent-filter>
                    <data android:scheme="http" android:host="www.website.com"/>
                    <data android:scheme="http" android:host="website.com"/>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                </intent-filter>
    </activity>

If I use one of my links from an email as below it gives me the chooser, launches my app, all is great, however, hitting the same link in the web browser just launches the page with no chooser. Any suggestions on what the problem might be?

http://www.website.com/share.aspx?id=12345678

Testing on GS2 running ICS 4.0.3 with Chrome and stock browsers.

Upvotes: 2

Views: 2738

Answers (2)

Hamid
Hamid

Reputation: 4440

This is how I solved it eventually:

<intent-filter>
            <data
                android:host="www.website.com"
                android:pathPattern=".*\\share.aspx"
                android:scheme="http" />
            <data
                android:host="website.com"
                android:pathPattern=".*\\share.aspx"
                android:scheme="http" />

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

Also add the following to the Activity tag:

android:exported="true"

The reason there are two addresses is so that the app can pick up canonical domains (with/without www.).

Upvotes: 2

RockoDev
RockoDev

Reputation: 524

Add the android:pathPrefix attribute.

<data android:scheme="http" android:host="website.com" android:pathPrefix="/" />

Upvotes: 2

Related Questions