Prevent activity dialog from closing on outside touch in android studio

Prevent activity dialog from closing on outside touch in android studio

2,215

Today I'm showing you how to prevent Material Design dialog box of closing when user touch outside of dialog in Android studio.

Solution 1:

dialog.cancelOnTouchOutside(false);

It is used to prevent dialog box by clicking outside the dialog box.

Solution 2:

dialog.cancelable(false);

It is used to prevent dialog box close by pressing back button.


Simple right?

- Last updated 3 years ago

Be the first to leave a comment.

You must login to leave a comment