I would like to know if I can freeze the current Activity, while I wait for another activity or dialog (any would do) to finish.
I know I can start an activity for results, and handle those there, but the code after startActivityForResult() will still get executed
this is something I would like to do:
PopupDialog dialog = new PopupDialog(this,android.R.style.Theme_Black_NoTitleBar);
dialog.show();
// wait here, and continue the code after the dialog has finishes
int result = getResultFromDialogSomehow();
if (result == 1){
//do something
}else{
//do something else
}
I know this must sound quite weird, but but I would really appreciate it if anyone can tell me how to achieve such functionality.
In a dialog, if you expect a result, you should use callback methods which can are executed when you click on the dialog’s buttons.
For example:
This way,
onClickmethod will not execute when you run the code, but it will execute when any of your buttons inside the dialog are tapped.