I've a MapView (v2) in an activity, and I enabled the my location button through
getMap().getUiSettings().setMyLocationButtonEnabled(true);
getMap().setMyLocationEnabled(true);
If the user clicks on the button then usually the map is centered on its position.
But after that many users reported that the button wasn't working I realized that the button works only if the location option in the google settings is enabled. Unfortunately I couldn't find a way to check if that option is enabled or not, so I'm not even able to tell the user to enable it.
If the location setting is not enabled I'd like to show the user a dialogbox similar to the one that appers in the same situation in the Google Maps application. But I can't know if the that setting is enabled or not!
You can do this via the LocationManager
. For example:
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments