Prevent activity dialog from closing on outside touch in android studio

Prevent activity dialog from closing on outside touch in android studio

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 4 months ago

Be the first to leave a comment.

You must login to leave a comment