2

Suppose you have an AlertDialog with two buttons A and B. I have found that on some devices and some versions of android, if you touch any area of the screen around the dialog, the AlertDialog disappears. On other devices you are forced to select either A or B, so there is no way I can allow the user to cancel the action without adding a third ('Cancel') option to the AlertDialog. Is there any way to determine programmatically whether the third option is required?

Paul Boddington
  • 37,127
  • 10
  • 65
  • 116

2 Answers2

3

You can control it with dialog.setCanceledOnTouchOutside(true);

For more information :

How to dismiss the dialog with click on outside of the dialog?

Community
  • 1
  • 1
Blaze Tama
  • 10,828
  • 13
  • 69
  • 129
0
Dialog dialog = new Dialog(context)
 dialog.setCanceledOnTouchOutside(true);
Harsh Parikh
  • 3,845
  • 3
  • 14
  • 14