0

I'm running ussd code from my code. After it returns the results the user will press the ok button to close the the dialog. I want to detect when the user does this.

Mutai Mwiti
  • 487
  • 1
  • 7
  • 20

1 Answers1

1

Let's assume that this is your dialog code:

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setTitle("dialog's title");
    builder.setMessage("dialogs's text");
    builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            //do stuff when user presses ok button
        }
    });
    builder.setNeutralButton("CANCEL", null); //same here just add the listener
    AlertDialog dialog = builder.create();
    dialog.show();
//you can use neutralButton as well
Thorvald
  • 3,424
  • 6
  • 40
  • 66