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 me the same dialog asking for location permission. I know those are both in the same group but Google says:
Note: Your app still needs to explicitly request every permission it needs, even if the user has already granted another permission in the same group. In addition, the grouping of permissions into groups may change in future Android releases. Your code should not rely on the assumption that particular permissions are or are not in the same group.
This means I ask for those 2 permissions within a second, which results in 2 dialog in a row. THis does not seem very user friendly to me. Is there a better way?
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
orGPS_PROVIDER
, you must request user permission by declaring either theACCESS_COARSE_LOCATION
orACCESS_FINE_LOCATION
permission, respectively, in your Android manifest file. For example:<manifest> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> ....... </manifest>
Without these permissions, your application will fail at runtime when requesting location updates.
Note: If you are using both
NETWORK_PROVIDER
andGPS_PROVIDER
, then you need to request only theACCESS_FINE_LOCATION
permission, because it includes permission for both providers. (Permission forACCESS_COARSE_LOCATION
includes permission only forNETWORK_PROVIDER
.)
Please look at https://developer.android.com/guide/topics/location/strategies.html