There is a first activity in which users save their details. After clicking the โSaveโ button, Alertdialog asks for confirmation or cancellation. if the user clicks the OK button, a new action will begin.
protected final Dialog onCreateDialog(final int id) { Dialog dialog = null; switch(id) { case DIALOG_ID: AlertDialog.Builder builder = new AlertDialog.Builder(AppointInformation.this); builder.setMessage("Information saved successfully ! Add Another Info?") .setCancelable(false) .setPositiveButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startActivity(new Intent(((Dialog)dialog).getContext(),CheckPatient.class)); } }) .setNegativeButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); dialog = alert; break; default: } return dialog; }
source share