If I have ACCESS_FINE_LOCATION already, can I omit ACCESS_COARSE_LOCATION?

后端 未结 2 1300
独厮守ぢ
独厮守ぢ 2020-12-13 12:05

I have a GPS app that already requests ACCESS_FINE_LOCATION permission in the manifest, now I want to add a library (MoPub) that requires ACCESS_COARSE_L

相关标签:
2条回答
  • 2020-12-13 12:15

    https://developer.android.com/guide/topics/location/strategies.html#Permission

    Note: 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 includes permission only for NETWORK_PROVIDER.)

    In short: yes, you don't need ACCESS_COARSE_LOCATION if you've already defined ACCESS_FINE_LOCATION.

    0 讨论(0)
  • 2020-12-13 12:33

    Depends on your need.

    Permission wise, ACCESS_FINE_LOCATION includes ACCESS_COARSE_LOCATION. However, there is a catch:

    ACCESS_COARSE_LOCATION gives you last-known location which is battery friendly https://developer.android.com/training/location/retrieve-current.html#setup
    For example, if your app does something like location-based recommendations, last-known location is good enough.
    This has a dependency on Google Play Services

    However, if you need something like live/ real-time location like Pokemon Go, use ACCESS_FINE_LOCATION
    It gives you live/ real-time location. You'll need to use a LocationListener
    Last time I checked, this does not require Google Play Services

    0 讨论(0)
提交回复
热议问题