googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

@AfterPermissionGranted,When using this annotation method, the method cannot take parameters #234

Closed youyuanme closed 6 years ago

youyuanme commented 6 years ago

@AfterPermissionGranted(RC_CAMERA_AND_LOCATION) private void methodRequiresTwoPermission(String str) { String[] perms = {Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION}; if (EasyPermissions.hasPermissions(this, perms)) { // Already have permission, do the thing // ... } else { // Do not have permissions, request them now EasyPermissions.requestPermissions(this, getString(R.string.camera_and_location_rationale), RC_CAMERA_AND_LOCATION, perms); } } When all the permissions of the application are allowed, the methods described above cannot execute, and only the parameters can be deleted.

samtstern commented 6 years ago

That is working as intended. Since the methods are called by reflection after the permission is granted we would have no idea what parameters to pass.