Dialogs / AlertDialogs: How to “block execution” while dialog is up (.NET-style)

Ted, you don’t want to do this, really 🙂 The biggest reason is that if you block the UI thread while you are displaying a Dialog, you will block the thread that’s in charge of drawing and handling the events of your Dialog. Which means your dialog will be unresponsive. You will also cause ANRs if the user takes more than a few seconds to click the dialog.

Erich’s answer is exactly what you need. I know it’s not what you want, but that doesn’t matter. We’ve designed Android to prevent developers from writing synchronous dialogs so you don’t really have much of a choice.

Leave a Comment