What I want basically is to have a logout button in the ActionBar, in such a way that when the user come back to the App, it will run as it was the first time. I've accomplished this exact behaviour calling:
android.os.Process.killProcess(android.os.Process.myPid());
on the Logout button handler, but I'm avoiding using such obscure hacks.
I've tried to do as described here Killing android application on pause , but the behaviour is not the expected. When the users come back, the application is already logged in. I must ensure that whenever the users log offs, the app will be reloaded the next time it runs.
I've also tried this: Android - How to start the exact same activity every time the app is opened up? . The behaviour is the same as finish()'ing on pause.
Please do not reply comment such as "why you want that, this is not how Android works, it manages the processes for you" and so on. I understand the lifecycle, as described here: http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle . What I want is not usual but absolutely necessary for the app I'm working with. If killing the process is the only answer, then unfortunatelly that is exactly what I'm going to do.