I am trying to clear every single activity on the stack by startActivity
method with the Intent
flags: (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY)
(I have an exit button that resets and finishes all activities and I tried all "how to make an exit button, how to terminate an app" questions/answers. They don't help me because of the singleInstance
launchMode
configuration of MainActivity
.
Normally this should work and finish current activity automatically without calling finish()
. However, as I marked MainActivity as singleInstance
in the AndroidManifest.xml
, it doesn't work. If I remove that singleInstance
, it works as expected.
If I call finish()
manually right after/before launching the MainActivity
to clear all the stack, finish()
will return the app to the previous activity on the stack. But I already launched the MainActivity
. So everything gets messed.
(I tried adding Intent.FLAG_ACTIVITY_SINGLE_TOP
and Intent.FLAG_ACTIVITY_MULTIPLE_TASK
too just to see if it changes anything and it didn't)
I need a solution which works with singleInstance
and which does not require manual finish()
.
Update 1: I try to launch this Intent
from a SingleTop
activity (but changing it changes nothing)
Update 2: I try this on Android 2.3.3 emulator