When should I use ACCESS_COARSE_LOCATION permission?

后端 未结 5 978
抹茶落季
抹茶落季 2021-01-31 13:31

I am building an Android app that will track the user\'s geolocation and draw their route on a map.

I am using the Google Play Services location API, as described here.<

5条回答
  •  無奈伤痛
    2021-01-31 13:46

    No you don't need to use coarse location.

    Coarse location is for network provider's location and fine location is for both GPS provider and network location provider. So fine location covers both and you don't need to use anther one.

    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 is a link for your reference.

提交回复
热议问题