Exit part of the code:
1 Private voidexit () {2 if(!isexit) {3Isexit =true;4Toast.maketext (Getapplicationcontext (), "Press again to exit the program",5 toast.length_short). Show ();6 //using handler delay to send Change status information7Mhandler.sendemptymessagedelayed (0, 2000);8}Else {9Utils.logout (walkmainactivity. This);TenUtils.disablebluetooth ( This); One finish (); ASystem.exit (0); - //android.os.Process.killProcess (Android.os.Process.myPid ()); - } the}
Get the Click Button event:
1 @Override2 Public BooleanOnKeyDown (intKeyCode, KeyEvent event) {3 if (keycode = = Keyevent.keycode_back) {4 Utils.hiddenprogram (Getapplicationcontext ()); 5}6 if(KeyCode = =Keyevent.keycode_menu) {7 drawerutil.openclosedrawerlayout ();8 }9 return Super. OnKeyDown (KeyCode, event);Ten}
There is also a mhandler part of the code.
Reference: http://tjlibaoh.blog.163.com/blog/static/2112264132012984518743/
Android Click two times Back button to exit the program