In a my Activity I call a method that shows an alert dialog and returns a response according the button clicked on the AlertDialog
and others checks (this method is in another class)
something like:
public static boolean showAlertDialog(Context c,int param){
...
AlertDialog.Builder alert = new AlertDialog.Builder(con);
alert.setTitle(title);
alert.setIcon(android.R.drawable.ic_dialog_info);
alert.setMessage(message);
alert.setPositiveButton(R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
...
}
}
);
....
alert.show();
return status;
}
The problem is that when I call this method the code doesn't wait that the user do his operation on AlertDialog
, but continues the execution.
so if in my activity do
boolean status=false;
status=Alerts.showAlertDialog(this);
if(status){
//do this
}
else{
//do that
}
always the else block is executed
How should I solve this?