Android Confirmation dialog returning true or false
问题 It seems to be there is no easy way to get an Alert dialog to return a simple value. This code does not work (the answer variable cannot be set from within the listener, in fact it does not even compile) public static boolean Confirm(Context context) { boolean answer; AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setTitle("Confirmation"); dialog.setMessage("Choose Yes or No"); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Yes", new