I used to be system.exit (0);
Today I saw someone say that this method is not very good. This is the method in J2se, he mainly by terminating the Java virtual machine being executed. Causes the program to terminate.
The following methods are recommended:
1. Kill this process:
Android.os.Process.killProcess (Android.os.Process.myPid ());
2. Force closure of all activities related to the package (killing other processes):
Activitymanager manager = (Activitymanager) getsystemservice (Context.activity_service); Manager.killbackgroundprocesses ("package name");
Due to the killing of other processes, we need to increase the privileges:
<uses-permission android:name= "Android.permission.RESTART_PACKAGES"/>
The following two ways to kill the process can still receive service, such as push. I don't have a chance (I tested it and I can receive it).
I used to use the System.exit (0);
2014.7.2 MORE:
Today, I saw someone say System.exit (0); it's a better way to get the program to quit normally.
The Android.os.Process.killProcess (Android.os.Process.myPid ()) is forced garbage collection. I go like a.
Android off app