androidlaunchmode

Relaunch specific activity from middle of the stack again by closing all activities above (including specific one)


I have activity stack

A>B>C>D>E>F

From Αctivity F I want to start Αctivity C again from fresh and close all C,D,E,F activities so the new Αctivity stack will be:

A>B>C(C as a Fresh activity)

I tried using singleTask to Activity C but it is not relaunching the Activity C. It is resuming the Activity C


Solution

  • Finally, I am answering my own question. If anyone is facing the same issue you can refer the answer.

    As I have researched a lot on the thing I wanted to achieve I came across this is not possible to relaunch the Activity C. So I solved it by adding launchmode singleTask to the Activity C. And from Activity F I am launching the activity C again and performing the task that I want to perform in onNewIntent() the overridden method on activity C.