-1

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.

ebs237
  • 184
  • 2
  • 11

2 Answers2

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,226
  • 14
  • 19
0

Use this to prevent dialog from being dismissed

dialog.setCancelable(false);

And use this to dismiss after your process is complete

dialog.dismiss();