When I try to turn on gps without going to the phone settings, I get this dialog:
How could I display a dialog with such a description?
Here is example of my code:
viewModel.onEnableGpsEvent.observe(this, Observer { event ->
event.getContentIfNotHandled()?.let {
activity?.let {
val locationRequest = LocationRequest.create()
locationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY
val builder = LocationSettingsRequest.Builder().addLocationRequest(locationRequest)
val task = LocationServices.getSettingsClient(it).checkLocationSettings(builder.build())
task.addOnSuccessListener { response ->
val states = response.locationSettingsStates
if (states.isLocationPresent) {
//TODO: Do something if need it
}
}
task.addOnFailureListener { e ->
if (e is ResolvableApiException) {
try {
// Handle result in onActivityResult()
e.startResolutionForResult(
it,
LOCATION_SETTING_REQUEST
)
} catch (sendEx: IntentSender.SendIntentException) {
}
}
}
}
Also i have next depedencies:
implementation 'com.google.android.gms:play-services-location:18.0.0'