To access the location manager you need to declare the proper permissions in the application manifest file.
If you will not define this permissions then the application will get a security exception (SecurityException) at run-time.
The permission depends on the methods used from LocationManager. The LocationManager in android.location package provide the two location provider methods.
1) GPS Providers
2) Network Location Based Providers
The ACCESS_COARSE_LOCATION permission is required if you will use the network location based providers.
The more accurate GPS Providers need the ACCESS_FINE_LOCATION permission.
defining the ACCESS_FINE_LOCATION permission implies ACCESS_COARSE_LOCATION permission automatically
The network based location providers need the internet access permissions also.
Example - Network based location providers permissions in manifest file
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" />
No comments:
Post a Comment