diff --git a/README.md b/README.md index dc75d2e..42aabfe 100644 --- a/README.md +++ b/README.md @@ -49,22 +49,27 @@ are enough. //... more code here if (!AllowMe.isPermissionGranted(permission)) { - AllowMe.requestPermissionWithRational(new AllowMeCallback() { - @Override - public void onPermissionResult(int requestCode, PermissionResultSet result) { - if (result.isGranted(permission)) { - //... handle your permission here - } - } - }, requestCode, rational, permission); + new AllowMe.Builder() + .setPermissions(permission) + .setRational(rational) + .setRationalThemeId(themeId) + .setCallback(new AllowMeCallback() { + @Override + public void onPermissionResult(int requestCode, PermissionResultSet result) { + if (result.isGranted(Manifest.permission.READ_CONTACTS)) { + onPermissionGranted(); + } + } + }).request(requestCode); } else { //... handle permission already granted } ``` - `permission` is the permission you need to request + - `rational` is optional and it is the string message to show when the user denies the permission for the first time + - `themeId` is optional and allows to style the rational alert dialog - `requestCode` is an integer to identify the request - - `rational` is the string message to show when the user denies the permission for the first time The library makes sure that `onPermissionResult` is only called when the `requestCode` matches the user input request code. Anyway, the `requestCode` is also returned in the callback in case the user diff --git a/library/src/main/java/com/aitorvs/android/allowme/AllowMe.java b/library/src/main/java/com/aitorvs/android/allowme/AllowMe.java index 8d363ee..173d090 100644 --- a/library/src/main/java/com/aitorvs/android/allowme/AllowMe.java +++ b/library/src/main/java/com/aitorvs/android/allowme/AllowMe.java @@ -228,6 +228,9 @@ private static Map> getRequestQueue() { return getInstance().mRequestList; } + /** + * Builder class + */ public static class Builder { private String rational; private int rationalThemeId = 0;