Search code examples
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.

  • From the Gmail app, my app launches and all works well. Clicking the ||| icon at the bottom of the screen shows my app is running standalone.
  • From Slack, my app launches and works fine, but it appears to be a part of the Slack process. The back button doesn't function, and if I click on the ||| icon at the bottom of the screen then it shows that my app appears to be running inside Slack (there's only one window open).
  • From WhatsApp, the same happens as Slack.

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.