I displayed two buttons, "GPS Setting" and "Cancel" and i want when Cancel button is pressed , it will show another dialog which has a "OK" Button . what to do in this case I am using the following code..
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();