Answer the question
In order to leave comments, you need to log in
How to close the window?
Hello! I am writing an application, I have reached the stage of checking whether GPS is enabled or not, if it is enabled, I go further according to the logic of the program, if not, I display a dialog and transfer the user to the location settings.
Dialog code:
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("GPS выключен, включить?")
.setCancelable(false)
.setPositiveButton("Да", new DialogInterface.OnClickListener() {
public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
dialog.cancel();
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
checkGpsStatus();
}
})
.setNegativeButton("Нет", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
checkGpsStatus();
}
});
final AlertDialog alert = builder.create();
alert.show();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question