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?
Asked
Active
Viewed 284 times
2

Paul Boddington
- 37,127
- 10
- 65
- 116
2 Answers
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
-
Thanks. I don't know how I missed that other question. – Paul Boddington Nov 18 '14 at 12:03
-
@pbabcdefp No problem, sometimes its hard to find a right keyword for googling :) I have known that link – Blaze Tama Nov 18 '14 at 12:17
0
Dialog dialog = new Dialog(context)
dialog.setCanceledOnTouchOutside(true);

Harsh Parikh
- 3,845
- 3
- 14
- 14