When I recently made a project, I accidentally discovered a way to get the Android program to quit completely, and thinking back to find an effective way to get the Android program to completely quit when the embarrassment, some feeling. Here dare not alone, and share with you, is also a point, I hope that Daniel out to continue to explore this issue.
The method is very simple, actually is a layer of window paper, know, will understand. Call the Linux system call exit with JNI. Here are the specific implementations:
Package Com.example.bitmaptest;import Android.util.log;public Final class Apputils {private static final String TAG = "App Utils "; static {system.loadlibrary (" Apputils ");} Private native void Native_exit ();p ublic Void exit () {LOG.D (TAG, "exit"), if (listener! = null) {Listener.onexit ();} Native_exit ();} public static interface Onexitlistener {void OnExit ();} Private Onexitlistener listener;public void Setonexitlistener (Onexitlistener listener) {This.listener = listener;} Public Onexitlistener Getonexitlistener () {return listener;}}
The JNI implementation is as follows:
jniexport void Jnicall java_com_example_bitmaptest_apputils_native_1exit (jnienv * env, Jobject obj) {exit (0); return;}
Note: After using this method, the following is found in log:
06-15 09:20:49.316:i/activitymanager (805): Process com.example.bitmaptest (PID 5784) has died.
06-15 09:20:49.316:i/windowstate (805): WIN death:window{4214d2f0 u0 com.example.bitmaptest/ Com.example.bitmaptest.MainActivity}
But because of the need to completely quit the app, so I think it doesn't matter.