1. Overview:There are five priorities for application deployment to a mobile phone: foreground process, visual process, service process, background process, empty process. Android, by default, will not kill the process, the purpose of this practice is: to open the application again when you can quickly start, save time. But this also brings a problem, there are many applications in the background to leave an empty process, which will occupy some memory space, affecting the speed of the phone. as a responsible programmer, we want to make sure that the application releases the corresponding process at the end.
2. Closing modeFirst: Get the ID of the current process first, and then kill the thread.
Gets the ID of the current process int pid = Android.os.Process.myPid (); This method can only be used for suicide operation Android.os.Process.killProcess (PID);
The second type: terminates the currently running Java Virtual machine, causing the program to stop.
<span style= "White-space:pre" ></span>system.exit (0);
The third type: forces all executions that are associated with the package to be closed.
Activitymanager am = (activitymanager) getsystemservice (activity_service); Am.killbackgroundprocesses (Getpackagename ());
The third need to add permissions:
<uses-permission android:name= "Android.permission.KILL_BACKGROUND_PROCESSES"/>
Android system off app