Many devices have the ability for us to obtain the location of the user in a very precise manner. Android provides a few means to access the location, including using the network or using Global Positioning System (GPS).
If we are designing an app that requires the user's location, such as finding things nearby, we can use LocationManager
to get the user's current location:
If we are only interested in using the network provider, we only need to ask for permission to use coarse location:
[assembly: UsesPermission( Manifest.Permission.AccessCoarseLocation)]
If we want to use GPS, we need to use the fine location permission instead:
[assembly: UsesPermission( Manifest.Permission.AccessFineLocation)]
Once we have permission for location requests, we need to get
LocationManager
:manager = LocationManager.FromContext(this);
We can check to see whether a specific provider, such as GPS, is enabled:
manager.IsProviderEnabled( LocationManager...