aarelovich
aarelovich

Reputation: 5566

How to simulate blocking dialog on Android?

First of all: I'd like to point out that I understand that is fundamentally against Androids design to use blocking dialogs but I have to do this thing and I don't know how to. And what it really comes down to is "simulating" a blocking dialog.

My program needs to fire a chain of events (essentially call one or more of a group of functions) that in certain conditions will require user input and cannot complete the function call util it gets the user choice. It may require it anywhere from 1 to N times. Or, as I said, not at all. This is a game, just so you know, and instructions on what the program needs to do (and consequently if the user needs to make a decision or not) are obtained by parsing a sequence of strings which are different commands.

With blocking dialogs this would be trivial. Hoewever I have no idea how to accomplish this behaviour in Android. Can any one give me any clues as to how to do this?

Thank you very much for any answers.

Upvotes: 0

Views: 163

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007359

First, there are better UI designs than this, such as a wizard with 1-N pages, where you skip the wizard in cases where it is not needed. This will be much more natural for the user, make it easier to move backwards and forwards through the series of steps, etc. It will also be easier to code than a series of 1-N dialogs, given existing wizard frameworks.

But, let's assume for the moment that an evil supervillian is holding the citizen of Major City hostage, unless you implement a series of 1-N dialogs.

Implementing this chain of dialogs does not require blocking dialogs. Show the next (or previous) dialog based upon the accept/cancel events from the current dialog, using an object to maintain your ongoing state.

in certain conditions will require user input and cannot complete the function call util it gets the user choice

That is not generally possible. Event-driven programming has been around for a couple of decades; the Android framework assumes that developers know how to implement event-driven programming.

Hoewever I have no idea how to accomplish this behaviour in Android

Android does not support blocking dialogs, as you have discovered.

However as I am simply doing an application on my free time as a hobbie, it will be difficult to do as you suggested

You do not have much of a choice in the matter.

Upvotes: 1

Related Questions