Search code examples
androidandroid-permissionsgoogle-geolocation

Basic geolocalisation permissions for native mobile applications


I did some research but I couldn't find what I'm looking for.

I'm looking for different permissions to allow google map localisation access to my android application, I found this ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION but I don't understand how to to make it work.


Solution

  • Check out this official website link that provides explanation about both permissions: https://developer.android.com/guide/topics/location/strategies.html#Permission

    To quote:

    In order to receive location updates from NETWORK_PROVIDER or GPS_PROVIDER, you must request the user's permission by declaring either the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission, respectively, in your Android manifest file. Without these permissions, your application will fail at runtime when requesting location updates.

    If you are using both NETWORK_PROVIDER and GPS_PROVIDER, then you need to request only the ACCESS_FINE_LOCATION permission, because it includes permission for both providers. Permission for ACCESS_COARSE_LOCATION allows access only to NETWORK_PROVIDER.

    This means, you will only need to use one of the two in your AndroidManifest.xml depending on your needs as stated above.

    Add the following to the manifest file and you should be good:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />