這是我的代碼。 (它使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();