Alex Rivera | Logout

Prevent Android activity dialog from closing on outside touch

Asked 2012-08-24T03:29:39.803
284

I have an activity that is using the Theme.Dialog style such that it is a floating window over another activity. However, when I click outside the dialog window (on the background activity), the dialog closes. How can I stop this behaviour?

Edit
Report

1 Answer

34

This could help you. It is a way to handle the touch outside event:

How to cancel an Dialog themed like Activity when touched outside the window?

By catching the event and doing nothing, I think you can prevent the closing. But what is strange though, is that the default behavior of your activity dialog should be not to close itself when you touch outside.

(PS: the code uses WindowManager.LayoutParams)

answered 2012-08-24T03:32:08.863

Your Answer