This repository was archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
doc: inconsistent sample code for AfterPermissionGranted annotation #354
Copy link
Copy link
Open
Description
Basic Information
Device type: any
OS version: any
EasyPermissions version: 3.0.0
Describe the problem
The library sample code states that methods annotated with @AfterPermissionGranted for a specific request code are called when all requested permissions are granted, which can be confirmed in the library source code. However, in the README sample code, there is a check if the requested permissions have been granted, which is completely confusing and should be considered dead code.
Code and logs
README Sample Code
@AfterPermissionGranted(RC_CAMERA_AND_LOCATION)
private void methodRequiresTwoPermission() {
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);
}
}Library permissions grant check to call annotated methods
easypermissions/easypermissions/src/main/java/pub/devrel/easypermissions/EasyPermissions.java
Lines 204 to 206 in 1d8c6e0
| if (!granted.isEmpty() && denied.isEmpty()) { | |
| runAnnotatedMethods(object, requestCode); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels