如何在Android中关闭用户关闭ussd对话框的时间?

时间:2017-09-20 09:04:53

标签: java android

我正在运行代码中的ussd代码。返回结果后,用户将按下确定按钮关闭对话框。我想检测用户何时这样做。

1 个答案:

答案 0 :(得分:1)

我们假设这是您的对话框代码:

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