Code Example
1: private void ShowMessageExit(String Message){
2: new AlertDialog.Builder(this)
3: .setMessage(Message)
4: .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
5: public void onClick(DialogInterface dialog, int which) {
6: android.os.Process.killProcess(android.os.Process.myPid());
7: System.exit(0);
8: }
9: })
10: .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
11: public void onClick(DialogInterface dialog, int which) {
12: // do nothing
13: }
14: })
15: .setIcon(android.R.drawable.ic_dialog_alert)
16: .show();
17: }
How to call
1: ShowMessageExit("Are you sure to exit?");
0 comments:
Post a Comment