I am working on an Android application which has logout button. When I click on that I need to close my app completely (I don't want to run the app in background as well).
I tried with System.exit(0) and finish() as well.
I am working on an Android application which has logout button. When I click on that I need to close my app completely (I don't want to run the app in background as well).
I tried with System.exit(0) and finish() as well.
the finish()-method runs the destruction of the activity. so, it should be right here.
Android has a mechanism in place to close an application safely.
In the last Activity on the stack (usually the main, or just the first you have started) override the onDestroy() method.
You can either call the System.runFinalizersOnExit(true) which ensures that all objects will be finalized and garbage collected when the the application exits, or kill an application quickly via android.os.Process.killProcess(android.os.Process.myPid()) if you prefer.