Why my deeplink don't work anymore when I have more than one host?

Viewed 16

When I have my deeplink as below defined in AndroidManifest.xml as below

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

                <data
                    android:host="example-host"
                    android:scheme="my-app" />

            </intent-filter>

I can perform a deeplink using adb shell am start -d my-app://example-host

However, after I add another host as below,

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

                <data
                    android:host="example-host"
                    android:scheme="my-app" />

                <data
                    android:host="example-host-2"
                    android:pathPattern="/"
                    android:scheme="my-app" />
            </intent-filter>

The result is

  • the adb shell am start -d my-app://example-host don't work anymore
  • the adb shell am start -d my-app://example-host-2/ works.
  • the adb shell am start -d my-app://example-host/ also works.

Why did the adb shell am start -d my-app://example-host don't work anymore? A bug in Android?

1 Answers

To workaround this issue, I'll have to split the host with pathPattern with the one without in different intent-filter

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

                <data
                    android:host="example-host"
                    android:scheme="my-app" />

            </intent-filter>

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

                <data
                    android:host="example-host-2"
                    android:pathPattern="/"
                    android:scheme="my-app" />
            </intent-filter>

With that, now all works

  • the adb shell am start -d my-app://example-host works
  • the adb shell am start -d my-app://example-host-2/ works.
  • the adb shell am start -d my-app://example-host/ also works.
Related