Source: http://www.open-open.com/home/space-37924-do-blog-id-5805.html
Here are some of the more simple three, interested in the text can be viewed through the link.
1. Local methods for Dalvik VMS
Android.os.Process.killProcess (Android.os.Process.myPid ())//Get PID
System.exit (0); Normal Java, C # Standard Exit method with a return value of 0 for graceful exit
2. Task Manager method
The first step is to show that the method runs on Android 1.5 API level 3 to be able, while requiring permissions
Activitymanager am = (activitymanager) getsystemservice (Context.activity_service);
Am.restartpackage (Getpackagename ());
System will, the package under, all processes, services, all killed, you can kill clean, to pay attention to add
<uses-permission android:name=\ "Android.permission.restart_packages\" ></uses-permission>
3. According to the activity's declaration cycle
We know that the Android window class provides a history stack, which we can skillfully implement using the stack principle, where we add the flag intent.flag_activity_clear_top directly to the Intent when opening the b window in a window. When you turn on B, all activity for that process space will be cleared.
In the a window, use the following code to invoke the b window
Intent Intent = new Intent ();
Intent.setclass (Android123.this, Cwj.class);
Intent.setflags (Intent.flag_activity_clear_top); Note the flag setting of the bank
StartActivity (Intent);
Next, in the b window you need to exit directly using the Finish method to exit all.
Four ways Android exits the app