Deep Link opens wrong app (instant app, not installed app)

I'm running into an issue with deep links when having an instant app and an installed app (version). My setup is as follows:

  • Base App (com.android.application)
  • Installed App (com.android.dynamic-feature with dist:instant="false", dist:onDemand="false")

Manifest.xml:

<application>
   <activity
      android:name=".Activity1">
      <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="https"
            android:host="example.com"
            android:pathPattern="/deeplink/*" />
      </intent-filter>
      ...
  • Instant App (com.android.dynamic-feature with dist:instant="true", dist:onDemand="false")

Manifest.xml:

<application>
   <activity
      android:name=".Activity2">
      <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="https"
            android:host="example.com"
            android:pathPattern="/deeplink/*" />
      </intent-filter>
      ...

(Notice that the installed app's manifest defines Activity1, whereas instant app's manifest defines Activity2)

The problem is, that when I open the installed app with a deep link, it opens Activity2 (the instant app's activity) instead of the installed app's activity.

I understand that gradle conducts a manifest merger for dynamic feature modules and the base app that merges all 3 manifests together (base app, installed app, instant app). But I thought android would be smart enough to use the installed app's activity to start the app if it's present on the device.

So my question is: How can you support the same deep link in the installed app AND the instant app at the same time? In other words: If the app is not installed, use instant app's activity (Activity2) to open the deep link, if the app is installed, use the installed app's activity (Activity1) to open the deep link?

Thanks for your help!



Read more here: https://stackoverflow.com/questions/64813146/deep-link-opens-wrong-app-instant-app-not-installed-app

Content Attribution

This content was originally published by Sebastian at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: