以下是我的AlertDialog的代码,取消AlertDialog在活动的onPause方法在Android的
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
alertDialog.setTitle("GPS settings");
alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
});
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alertDialog.show();
@Override
protected void onPause() {
super.onPause();
// I want dialog to be dismissed here
}
其工作正常,但我想要的是关闭该对话框中的活动的onPause方法,
我如何能实现它呢?
使用dialog.dismiss()函数... – 2014-11-21 06:34:03