Google Maps Api Android V2 - "access_fine_location" Permission Required With My-location Layer Enabled
Solution 1:
You can use the LocationSource
pattern to supply your own locations, which could come from whatever. LocationSource
is an interface, which you would implement on some object that can supply location data. You register this with setLocationSource()
on the GoogleMap
. You implement activate()
and deactivate()
methods on your LocationSource
that will get called to let you know when you should start and stop pushing over locations. As you get location fixes in, you call onLocationChanged()
on a supplied OnLocationChangedListener
.
This sample project demonstrates the use of LocationSource
.
Solution 2:
Is it possible to prevent the GoogleMap from trying to get the location from the GPS?
Default implmentation of LocationSource
doesn't necessarily have to use GPS to return accurate locations.
If I remove the permission "ACCESS_FINE_LOCATION" in the Manifest file, as soon as I try to display the map, the app crashes
This is because the default implementation uses LocationClient
with LocationRequest.PRIORITY_HIGH_ACCURACY
.
For now you can do nothing more than following CommonsWare's answer, but I also encourage you to create a feature request on gmaps-api-issues, so the default implementation doesn't fail when doing GoogleMap.setMyLocationEnabled
when you request only ACCESS_COARSE_LOCATION
permission, but switches to LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY
.
Post a Comment for "Google Maps Api Android V2 - "access_fine_location" Permission Required With My-location Layer Enabled"