I have the registered below activity in AndroidManifest for being opened when I run deeplink
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:exported="true"
android:theme="@style/Theme.TestDeeplink">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="testdeeplink" />
</intent-filter>
</activity>
After the above activity is opened, it will navigate to below activity when user tap on the test button
<activity
android:name=".DashboardActivity"
android:label="DashboardActivity"
android:theme="@style/Theme.TestDeeplink"/>
I test with command line and it show like below logs
First time:
adb shell am start -d testdeeplink://test
Starting: Intent { dat=testdeeplink://test }
Second time:
adb shell am start -d testdeeplink://test
Starting: Intent { dat=testdeeplink://test }
Warning: Activity not started, intent has been delivered to currently running top-most instance.
If app has already navigated to DashboardActivity, its onNewIntent method is not called
Otherwise app stay at MainActivity, its onNewIntent method is called with expected value
How to force app to open MainActivity every time the deeplink is called ?
Updated: I changed launchMode of MainActivity from singleTop to singleTask or singleInstance. The behaviosr is ok, anyone helps me to explain more detail about this ?