This is weird. I mean, I have strong network, and GPS is turned On, still it asks for Wifi !!
I'm using new Location Api with class FusedLocationProviderClient
.
This is how I am checking if Location Settings are enabled or not:
private void checkIfLocationSettingsAreEnabled() {
LocationRequest locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
locationRequest.setInterval(10000);
locationRequest.setFastestInterval(5000);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
builder.addLocationRequest(locationRequest);
builder.setAlwaysShow(true);
SettingsClient client = LocationServices.getSettingsClient(context);
Task<LocationSettingsResponse> locationSettingsResponseTask = client.checkLocationSettings(builder.build());
locationSettingsResponseTask.addOnSuccessListener(locationSettingsResponse -> {
getLastKnownLocation();
});
locationSettingsResponseTask.addOnFailureListener(e -> {
if (e instanceof ResolvableApiException) {
myLocationListener.onResolutionNeeded(e);
} else {
myLocationListener.onLocationFailure(e);
}
});
}
With the above code, I am able to get below image:
But then, after clicking OK, again I make call to checkIfSettingsAreEnabled()
this shows another popup as below:
I wonder why enabling Wifi is mandatory, even if I am on desert safari, where there is no Wifi to connect to !!
Is there any way to Skip this Wifi
option, and work as normal as Google Maps does ?
In fact, Google Maps uses priority PRIORITY_HIGH_ACCURACY
and still once, the first settings dialog has been shown, it doesn't ask second time to turn on Wifi.
FusedLocationProvider
uses a combo of GPS
and WIFI
to get your location. Especially when asking for balanced mode, it needs both or won't work (GPS
takes power, so it won't rely just on it for balanced). Try max accuracy, its less likely to use it then. Or just use the GPS
provider if you actually want GPS
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With