I am making a game in which certain events require every player to input their reaction, out of the normal game flow. For example, with 4 human players, four dialogs will pop-up in a row to ask each player what they want to do. This is the only way I found to wait for the input.
int counter = 0;
void askInput() {
counter++;
if (counter > max)
return;
// initialize dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.title)
.setNegativeButton(R.string.button, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
askInput();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
This seems sketchy to me. What would be the Android way to do this?
Well, after reflection it doesn’t seem so sketchy.