This code is working 100% just fit it as you like. All this where c
is passed as a context.
Declare this in your activity snd replace activity name with your activities name:
Context c = ActivityName.this;
AlertDialog.Builder builder = new AlertDialog.Builder(c);
builder.setTitle(R.string.confirm);
builder.setMessage(R.string.deleteConfirm);
builder.setPositiveButton(R.string.deleteBtnTxt,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.no,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();