【发布时间】:2017-11-29 20:48:36
【问题描述】:
我问的是之前在以下链接中提出的相同问题,但这些链接中提出的解决方案对我不起作用,所以我再次发布。
How to make an AlertDialog disappear?
Android AlertDialog always exits when I click on OK Button
How to navigate to next activity after user clicks on AlertDialog OK button?
基本上,我正在创建一个 AlertDialog 构建器来通知用户要求启用使用数据访问的设置,当按下确定按钮时,设置菜单就会打开。当我按下返回按钮返回应用程序时,AlertDialog 仍然可用,尽管我预计会被解雇以返回我的应用程序。
public void show_alert(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("This application requires access to the Usage Stats Service. Please " +
"ensure that this is enabled in settings, then press the back button to continue ");
builder.setCancelable(true);
builder.setPositiveButton(
"OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);
dialog.dismiss();
}
});
builder.show();
return;
}
任何提示可能会出现什么问题?
【问题讨论】:
标签: android android-alertdialog