4

I have an ActivityA and an ActivityB (in a library module). I navigate from ActivityA to ActivityB via startActivity().

Inside ActivityB I have a NavHost and a Composable which is resolving a deeplink.

When I press back, I have the ActivityA in the back stack but when I launch the ActivityB via a deep link URI, ActivityA in the backstack seems to have destroyed(printed onDestroy to confirm it) since the back stack is empty when I press back from ActivityB, the application closes.

Both Activity A & B has the launch mode as SingleTask. Any help in understanding why ActivityA is getting destroyed is deeply appreciated.

Flow 1 

    startActivity(Intent
(this,ActivityB::class.java))


            startActivity()             backpress()
ActivityA ------------------> ActivityB -----------> ActivityA  


Flow 2

val intent = Intent()
intent.data = "activityB://test"
startActivity(intent)

           via URI (deeplink)              backpress()
ActivityA --------------------> ActivityB -------------> Closes application 
        |
        |
        |
        ------>ActivityA
                destroyed
Vikram Ragu
  • 169
  • 1
  • 8
  • Hello @Vikram Ragu, did you found any solution for this. I too have same issue. – Raj Oct 10 '22 at 16:06
  • Hi @Raj, I couldn't find a solution yet. Btw, is your destination activity a compose screen? – Vikram Ragu Oct 10 '22 at 16:40
  • yes, I have Activity A -> DeeplinkActivity with In-App Link -> Activity B. by the time Activity B is started, Activity A & Deeplink activities are destroyed. My requirement is like when Activity B is opened, Activity A also should be there in stack, and that(Activity A) should appear on Back press from Activity B – Raj Oct 10 '22 at 17:07
  • @Raj, I'm unable to find a concrete solution :( – Vikram Ragu Oct 10 '22 at 17:14

0 Answers0