UPDATE : Beware, according to the comments, this does NOT work in all cases !!!
The solutions listed here on SO seem to me too complicated. I came up with this:
Create a static variable accessible from all your Activities to determine the number of currently running.
public class SharedData { static int runningActivities = 0; }
In each action, override two methods.
public void onStart() { super.onStart(); if (SharedData.runningActivities == 0) {
You can create an active MyActivity, put this code in it, and make all your actions extended for this class.
source share