KasparTr
KasparTr

Reputation: 2458

Android deep link not working

I want to get my app to work with deep links. For starters I want my app to be shown on chooser dialog when I type in www.example.com/gizmos For that as is my understanding I have to nothing else than modify AndroidManifest.xml

My AndroidManifest.xml

...
<activity
        android:screenOrientation="portrait"
        android:name=".activity.Landing"
        android:label="@string/title_activity_maps" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <!-- FOR DEEP LINKS-->
        <intent-filter>
            <data android:scheme="example"
                android:host="gizmos" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
</activity>

Now when I type in to notepad, browser, etc "www.example.com/gizmos" the page opens up in browser but no chooser dialog appears where my app should be an option.

What am I missing here?

Upvotes: 1

Views: 2409

Answers (2)

Thomas R.
Thomas R.

Reputation: 8063

To test deep linking you can use ADB console. Modify the following command to your needs:

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://www.example.com/gizmos"

If you need query parameters the command should look like this:

adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://www.example.com/gizmos?myKey=myValue"'

And your data tag should look like this:

<data
  android:host="www.example.com"
  android:path="/gizmos/"
  android:scheme="http"/>

Upvotes: 1

Mattia Maestrini
Mattia Maestrini

Reputation: 32820

You are using a wrong intent-filter. Try with this one:

<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="www.example.com"
        android:pathPrefix="/gizmos"
        android:scheme="http"/>
</intent-filter>

Upvotes: 1

Related Questions