Deep link does not work if the app is opened by deep link already.
However, if I open the app not by triggering a deeplink, like clicking the app icon to open the app. Then triggering deeplink afterward would always work.
Here come the details:
So I have my activity set up like this in AndroidManifest, namely LaunchActivity.
<activity
android:name="some.package.name.LaunchActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.SomeTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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:scheme="dlscheme" android:host="dlhost" />
</intent-filter>
</activity>
And in LaunchActivity, I would print a log in onCreate() to indicate that it have been there.
I used
adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name
to test the deep link.
With the app killed, I used the above command. It can open the app and route to the correct activity, no problem. And have the following log.
adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name
Starting: Intent { act=android.intent.action.VIEW dat=dlscheme://dlhost/param pkg=some.package.name }
Status: ok
Activity: some.package.name/.activity.LaunchActivity
ThisTime: 898
TotalTime: 898
WaitTime: 919
Complete
However, if I enter the same command again, without killing the app. It would only open the app, but it will not open the correct activity, and produce the following log.
adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name
Starting: Intent { act=android.intent.action.VIEW dat=dlscheme://dlhost/param pkg=some.package.name }
Warning: Activity not started, its current task has been brought to the front
Status: ok
Activity: some.package.name/.activity.LaunchActivity
ThisTime: 0
TotalTime: 0
WaitTime: 6
Complete
with this extra line
Warning: Activity not started, its current task has been brought to the front
I actually also tried this with a website, using this chrome intent:
intent://dlhost/param#Intent;scheme=dlscheme;package=some.package.name;end
and it would behave the same.