What would you look for, FLAG_ACTIVITY_CLEAR_TOP flag of intent:
If it is set, and the launched activity is already running in the current task, instead of launching a new instance of this action, all other actions on top of it will be closed, and this intention will be delivered to (now above) the old activity as a new intention.
Intent i = new Intent(..); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
and then run Activity with this intention.
For more information on tasks and the reverse stack, see the documentation: Tasks and Stop File .
However, to implement login / logout into the application (if it does not interact with the online service), you can use SharedPreferences . Thus, when starting the application, you can check whether the user is registered (for example, a certain flag is enabled in the settings) and when the application exits (for example, by clicking a button), you can clear this flag.
Killing / Removing Actions must be left on the system. For system design, the Android OS is responsible for the life of the application.
For example, check the sources of Password Safe . It requires a password every time you open a new instance of the application.
source share