I want to restrict dismissal of dialogs in my android app to a particular event. How can I go about it. I want the dialog to dismiss only after a certain process is completed. such that if the user clicks outside the dialog the dialog does not close.
Asked
Active
Viewed 49 times
-1
-
set dialog cancelable to false – Rahul Kushwaha Feb 13 '21 at 05:43
2 Answers
0
For prevent close on outside touch
dialog.setCanceledOnTouchOutside(false);
Override the onTouchEvent Event of the dialog
public boolean onTouchEvent(MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_OUTSIDE){
//certain process
}
return false;
}

Yasiru Nayanajith
- 1,647
- 17
- 20
0
Use this to prevent dialog from being dismissed
dialog.setCancelable(false);
And use this to dismiss after your process is complete
dialog.dismiss();

Porush Manjhi
- 135
- 12