Я отобразил две кнопки: «Настройка GPS» и «Отмена», и я хочу, чтобы при нажатии кнопки «Отмена» отображалось другое диалоговое окно с кнопкой «ОК». что делать в этом случае, я использую следующий код..
if (!isGPSEnabled) {
// no GPS provider is enabled
// creating alertdialog
AlertDialog.Builder builder = new AlertDialog.Builder(c);
builder.setTitle("Settings");
builder.setMessage("Enable GPS for the Application");
builder.setPositiveButton("GPS Setting",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new AlertDialog.Builder(MainActivity.this)
.setTitle("How to use Application")
.setMessage(
"You must enable the GPS in order to use this application. Press Activate and then press Power Button twice in order to send the alert message to the selected contacts")
.setNeutralButton(
"OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
// do something
/* Intent inmainact = new Intent(
getApplicationContext(),
MainActivity.class);
startActivity(inmainact); */
dialog.cancel();
}
}).show();
dialog.dismiss();
}
});
builder.show();