@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { new AlertDialog.Builder(this).setTitle("提示").setMessage("确定退出吗?") .setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub finish(); } }) .setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).show(); return true; }else{ return super.onKeyDown(keyCode, event); } } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); System.exit(0); // 或者下面这种方式 // android.os.Process.killProcess(android.os.Process.myPid()); }