-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.

The Codepreneur
  • 236
  • 3
  • 12

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,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