Android has a mechanism that allows you to safely close the application.
In the last action on the stack (usually the main or only the first that you run), override the onDestroy() method.
You can either call System.runFinalizersOnExit(true) , which ensures that all objects will be finalized and garbage will be collected when the application exits, or quickly delete the application through android.os.Process.killProcess(android.os.Process.myPid()) , if you want.
source share