The android system disables the application. The android system disables the application.
1. Overview: There are five priorities for processes where applications are deployed on mobile phones: foreground processes, visual processes, service processes, background processes, and empty processes. In the android system, the process is not killed by default. The purpose of this method is to enable the application quickly and save time. However, this also brings about a problem. Many applications leave a blank process in the background, which occupies some memory space and affects the running speed of mobile phones. As a responsible programmer, we must ensure that the application releases the corresponding process at the end.
2. First, get the id of the current process and then kill the thread.
// Obtain the id int pid of the current Process = android. OS. Process. myPid (); // This method can only be used for suicide operation android. OS. Process. killProcess (pid );
Type 2: Terminate the currently running Java virtual machine, causing the program to stop.
System. exit (0 );
Third: Disable all executions associated with the package.
ActivityManager am = (ActivityManager) getSystemService (ACTIVITY_SERVICE); am. killBackgroundProcesses (getPackageName ());
Third, you need to add permissions:
<Uses-permission android: name = "android. permission. KILL_BACKGROUND_PROCESSES"/>