How to check if dialog is displayed or display multiple dialogs of the same type?

pixel picture pixel · Jun 30, 2010 · Viewed 66.9k times · Source

I'm managing dialogs by showDialog/dismissDialog/removeDialog.

I want to:

Display several dialogs in kind of a stack:

a) First dialog is shown using showDialog(DIALOG_TYPE)

b) Next dialogs are shown on top of the existing dialog

Now I'm only able to display first dialog using showDialog and then next dialogs are ignored.

Display last dialog:

a) First dialog is shown using showDialog(DIALOG_TYPE)

b) Application checks if dialog is displayed, closes dialog (if it's displayed) and opens a new dialog.

Is there any possibility to achieve one of the above solutions?

Answer

Robby Pond picture Robby Pond · Jun 30, 2010

Dialog has an isShowing() method that should return if the dialog is currently visible. So you can use that to see if a dialog is showing and hide it with dismissDialog(). You just have to keep a reference to the Dialogs you create in onCreateDialog().