Program sometimes inadvertently click the exit button to quit the program, you need to set the exit key to monitor the Click event, to determine whether to exit.
Directly on the code, can be placed in the Exit button monitoring Click event inside
Alertdialog.builder Builder =NewBuilder ( This);
Builder.setmessage ("Are you sure you want to quit? ");//Prompt Information//Monitoring ConfirmationBuilder.setpositivebutton ("Confirm",NewAlertdialog.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss ();//Cancel dialog boxSystem.exit (0);//Exit Program }});//Monitor CancelBuilder.setnegativebutton ("Cancel",NewAlertdialog.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss ();//Cancel dialog box }});//Create dialog after show, or show directlybuilder.create (). Show ();
android dialog box "OK to exit?" ”