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-.
source share