我有以下代码来显示一个警报对话框以打开 Locations Service Settings :
alert = new AlertDialog.Builder(context).create();
alert.setTitle("Unable to Retrieve Current Location");
alert.setMessage(" Enable Location Service ?");
alert.setButton(DialogInterface.BUTTON_POSITIVE,"Open Settings", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
alert.dismiss();
Intent intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS);
context.startActivity(intent);
}
});
alert.setCancelable(false);
alert.show();
设置正常打开,但是当我按回时,上一个对话框不会被关闭。从设置返回时如何关闭对话框。