androidapplinksandroid-app-links

Android app links launching my app within the calling app


I've just setup App Links within my Android app, following the official Android guides online. I can click on a link and my app launches just fine.

However, I observe different behaviour depending on where the link was clicked from.

This is from my AndroidManifest.xml:

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

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

                <data
                    android:scheme="https"
                    android:host="mydomain.com"
                    android:path="/" />
            </intent-filter>

I suspect this is somehow related to Slack opening web links itself, but I don't know how to prevent this. This also doesn't explain the WhatsApp behaviour, as WhatsApp already seems to open web links in Chrome independently.

Any advice would be appreciated!


Solution

  • That's actually the default in Android- your app is launched as part of the caller's stack. You need to set the launch mode to singleTask in the manifest. Please note that this may sometimes cause onNewIntent to be called rather than a standard activity creation path, if the activity is already alive in the background.