Android系统对话框弹出无法取消。

4

我正在尝试关闭系统对话框,但该对话框仅有“确定”按钮,并且无法通过返回按钮取消。我尝试了两种方法。首先是在广播中

public void onReceive(Context context, Intent intent) {
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.getApplicationContext().sendBroadcast(closeDialog);}

第二

@Override
public void onWindowFocusChanged(boolean isTrue) {
    super.onWindowFocusChanged(isTrue);

    if (!isTrue){
        Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        sendBroadcast(closeDialog);
    }
}

但是没有人在工作。有什么帮助吗?

enter image description here


你想要关闭哪个对话框? - tyczj
请让用户点击“确定”按钮。 - CommonsWare
1个回答

1
您可以使用类似以下的代码:
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // 用户取消了对话框 } });

1
它是系统对话框,我无法通过编程进行更改。 - Eli Elezra

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接