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.
Asked
Active
Viewed 177 times
0
-
show your code. – Ankita Sep 20 '17 at 09:07
-
this might help https://stackoverflow.com/a/34132003 – Ashish Ranjan Sep 20 '17 at 09:08
1 Answers
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