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.
You can use onActivityResult
also
In your main activity callstartActivityForResult(intent, 1); //here 1 is the request code
In your Dialog class
Intent intent = new Intent(); intent.putExtra(....) //add data if you need to pass something setResult(2,intent); //Here 2 result code
so your main activity
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ if (resultCode == 2 && requestCode ==1){ //do something }else{ //do something else } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With