-1

I am developing an application using alertdialog. When my app starts i noticed that the user can prevent my alertdialog...

Example

enter image description here

if someone click outside of my alertdialog then dialog will disappear... I want to lock my alertdialog, so the user will be forced to choose!

Device
  • 993
  • 3
  • 11
  • 26
  • 2
    possible duplicate of http://stackoverflow.com/questions/12102777/prevent-android-activity-dialog-from-closing-on-outside-touch – random Jun 22 '15 at 12:03
  • 1
    There are tonnes of answers for this on SO – kev Jun 22 '15 at 12:11

4 Answers4

2

Add below line to your dialog

mdialog.setCanceledOnTouchOutside(false);
Madhu
  • 1,780
  • 23
  • 47
1

Try this:

  Window window = dialog.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    dialog.show();
Aman Arora BB
  • 190
  • 1
  • 12
1

You can set false in cancel method.

progressDialog.setCancelable(false);

Then your progressDialog will not cancel, until you cancel it.

Shoeb Siddique
  • 2,805
  • 1
  • 22
  • 42
1

Apply

setCancelable(false)

to your AlertDialog.Builder instance.

Sunny Garg
  • 1,073
  • 1
  • 6
  • 13