MarshMallow permission for gmaps

If gmaps needs the following permissions:

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
  • Should I ask each user using requestPermissions ?
  • I checked several times, and this only crashes, saying that the user did not give permissions for android.permission.ACCESS_FINE_LOCATION , but not others, why?
+6
source share
2 answers

Should each user requestPermissions ?

First, when to use requestPermission?

requestPermission is a call only after checkSelfPermission , when this method does not return PERMISSION_GRANTED .

You can find the list of permissions that Android M requires at runtime. Each of these permissions is a member of the permission group. WRITE_EXTERNAL_PERMISSION - from android.permission-group.STORAGE and ACCESS_COARSE_LOCATION / ACCESS_FINE_LOCATION from android.permission-group.LOCATION .

If the user allows access to the permission - for example, ACCESS_COARSE_LOCATION - then the android will automatically provide access to this permission group permission-group.LOCATION -. Therefore, if you later checkSelfPermission for ACCESS_FINE_LOCATION , you should get PackageManager.PERMISSION_GRANTED .

When the application crashes, this means that you tried to call, for example, LocationServices.FusedLocationApi.requestLocationUpdates before asking the user for the location of the permission group.

Edit:

Remember that requestPermission asynchronous . Therefore, do not call a method that requires permission immediately after requestPermission . To call a method that requires permission, you must override onRequestPermissionsResult , which will give you a list of permissions and their status -granted / denied-.

+3
source

You only need to request permission for the LOCATION and STORAGE groups. I am also sure that the exact location includes permission for Coarse, so you do not need to include this line in your manifest.

+3
source

All Articles