1

I have 2 activtity MainActitvity(launchMode: standard) and DeepLinkingActivity(launchMode: standard)

 <activity
      android:name=".feature.deepLink.DeepLinkActivity"
      android:launchMode="standard">
      <intent-filter
        android:autoVerify="true"
        tools:targetApi="m">
        <action android:name="android.intent.action.VIEW" />

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

        <data
          android:host="${deepLinkURI}"
          android:path="@string/path_prefix"
          android:scheme="https" />
      </intent-filter>
</activity>

<activity
    android:name=".feature.main.MainActivity"
    android:launchMode="standard"
    android:windowSoftInputMode="adjustPan|stateAlwaysHidden"/>

When the MainActivity is presented, I click on a link that will open the DeepLinkActivity. From the doc

https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks

The DeepLinkingActivity should be started in the same Task as MainActivity and placed on the top of that Task. It appears not, MainActity and DeepLinkingActivity now live in 2 separate Tasks (Pressing back on DeepLinkingActivity navigates me to the Launcher screen instead of MainActivity).

I did try to change the launchMode of DeepLinkingActivity to singleTask. It started DeepLinkingActivity in the same task MainActivity but it also cleared the back stack (There is no MainActivity to go back to)

So, how can I make DeeplinkingActivity placed on top of MainActivity in the same Task when I start it from a deep link.

Harvey
  • 1,353
  • 1
  • 14
  • 27
  • Same problem here! – tobidude Nov 09 '20 at 05:03
  • @tobidude Actually, I have dropped the multiple activities pattern. The new idea is the app only has one and only one activity. Other UI/screen will be Fragment. So when a deep link comes, only the MainActivity get notified and I have full control over the Fragment order. Hope this will give you some good ref. – Harvey Nov 09 '20 at 08:41
  • Hi thanks for this, but in my case, the app always opens a brand new activity from root and forgets the old, so this would help. – tobidude Nov 12 '20 at 03:57

1 Answers1

-2

put code in this method,

override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)

    }
  • Put what in onNewIntent? DeepLinkingActivity will be the one who get the Intent from OS not MainActivity – Harvey Mar 03 '20 at 10:02