I\'ve got 4 activities say Act1
, Act2
, Act3
and Act4
.
A button in Act1 opens Act2, a button in Act2 opens Act3, a button in A
If you have another activity behind ( in the application activity stack),
you could use finish()
to exit the current activity.
However, the back function too suppose to remove the current activity from your application activity stack.
In my experience, it is very unreliable to rely on the activities in the back stack ( in the application activity stack). Because of that I used to exit each activity when I go deeper.
In your case:
Act 1 -> exit -> Act 2 -> exit -> Act 3 -> exit -> Act 4 -> exit -> Act 1 -> exit
The above method will exit all the activities.
However, if you want to run some code in the background, it is better to rely on a "Service" rather than an "Activity". You can let the "Service" exit after doing its assigned work.