Marshmallow FINE and COARSE location permission

后端 未结 2 1848
失恋的感觉
失恋的感觉 2021-02-12 19:13

I\'m trying to access ACCESS_FINE_LOCATION and if it cannot be found access ACCESS_COARSE_LOCATION. So I request for those 2 permission, but they give

2条回答
  •  鱼传尺愫
    2021-02-12 19:59

    You do not need ACCESS_COARSE_LOCATION permission when you define ACCESS_FINE_LOCATION permission.

    From Android Documentation:

    Requesting User Permissions

    In order to receive location updates from NETWORK_PROVIDER or GPS_PROVIDER, you must request user permission by declaring either the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission, respectively, in your Android manifest file. For example:

    
          
           .......
    
    

    Without these permissions, your application will fail at runtime when requesting location updates.

    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.)

    Please look at https://developer.android.com/guide/topics/location/strategies.html

提交回复
热议问题