android Messagebox doesn’t show because of finish call, how to make this function wait for ok and then close
public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage(str2);
dlgAlert.setTitle(str);
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();
finish();
}
should be like this
public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setTitle(str);
dlgAlert.setMessage(str2);
dlgAlert.setPositiveButton("OK",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
}
});
dlgAlert.setCancelable(true);
dlgAlert.create().show();
}
see SO question: AlertDialog doesn't wait for input
you will have to implement callback (OnClickListener) when user clicks OK on AlertDialog.
This all because Android dialog boxes are not modal (non-blocking invoker thread)