android messagebox not showing due to call complete how to make this function wait 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 that
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(); }
source share