简体   繁体   English

如何检测用户何时关闭Android中的usd对话框?

[英]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.

相关问题 Android Java:当对话框关闭时,如何防止我的对话框短暂显示 MainActivity appname? - Android Java: How do I prevent my Dialog box from showing MainActivity appname briefly when the Dialog closes? 如何检测用户是否通过红十字关闭了窗口? - How can I detect if a user closes the window via the red cross? 在Android中打开警报对话框时如何等待用户输入 - How do I wait for user input when opening a alert dialog in android 检测用户何时关闭浮动工具栏框架 - Detect when user closes floating toolbar frame 如何在Android应用程序的警报对话框中为用户输入编码? - How do I code for user input in an alert dialog for an android app? 即使用户在 android studio 中关闭应用程序,如何保持登录状态 - How to remain signed in even when the user closes the app in android studio 如何检测用户取消AccountPicker对话框Android Eclipse - How To Detect User Cancel AccountPicker dialog Android Eclipse 如何在android上运行USSD命令? - How to run USSD commands on android? 用户关闭笔记本电脑屏幕时Java检测? - Java detect when user closes down the laptop screen? 如何检测 SWT 对话框已打开并且可见? - How do I detect that a SWT dialog has been opened and is visible?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM