DontPanic
DontPanic

Reputation: 2406

Dialog dismissed/hidden on Touch of Background Activity?

I've noticed a troubling behavior wherein a dialog disappears on touch of background activity screen. Is this expected? Is there any way to suppress this behavior?

Details:
My app displays an image using a custom view control. Upon selection of a MenuItem, a dialog is displayed to change parameters of the displayed image. All works fine unless I touch on the background image, then the dialog disappears or is hidden (I can't tell which). (Note: The background activity does have an onTouchEvent override in place but it does nothing to overtly cause this behavior).

This is a troublesome but not a showstopper. I have to forcibly dismiss the zombie dialog on refresh of the background, but this seems rather crude. Any suggestions or enlightenment would be greatly appreciated.

Upvotes: 0

Views: 521

Answers (2)

Sergey Glotov
Sergey Glotov

Reputation: 20346

setCancelable(false) will work, but it also affects behaviour of dialog on back press. Dialog will not be cancelled on back button press. If it matters you can use dialog.setCanceledOnTouchOutside(false).

Link to documentation.

Upvotes: 1

kandroidj
kandroidj

Reputation: 13932

try adding:

 dialog.setCancelable(false);

Upvotes: 1

Related Questions