Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
aitorvs committed Dec 5, 2015
1 parent 6ee6155 commit f25dda5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ private static Map<String, ArrayList<AllowMeCallback>> getRequestQueue() {
return getInstance().mRequestList;
}

/**
* Builder class
*/
public static class Builder {
private String rational;
private int rationalThemeId = 0;
Expand Down

0 comments on commit f25dda5

Please sign in to comment.