[英]How do I detect when user closes ussd dialog in Android?
I'm running ussd code from my code. 我正在从代码中运行usdd代码。 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.
我想检测用户何时执行此操作。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.