这是我的代码。 (它使alertdialog移动设置) 但我只想启用GPS时,我“启用GPS”按钮单击。 和安卓总是启用按钮点击时,我运行的应用程序不只是运行一次?android GPS启用按钮点击
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your GPS is disabled! Would you like to enable it?")
.setCancelable(false)
.setPositiveButton("Enable GPS",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
moveConfigGPS();
}
}).setNegativeButton("Do nothing",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();