Closed LeonChen1024 closed 6 years ago
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here (e.g. I signed it!
) and we'll verify it.
I signed it!
CLAs look good, thanks!
This actually already exists! The request perms method takes a callback that will be notified immediately if the permission has already been granted.
@SUPERCILEX
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
public void locationAndContactsTask() {
if (hasLocationAndContactsPermissions()) {
// Have permissions, do the thing!
Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show();
} else {
// Ask for both permissions
EasyPermissions.requestPermissions(
this,
getString(R.string.rationale_location_contacts),
RC_LOCATION_CONTACTS_PERM,
LOCATION_AND_CONTACTS);
}
}
In sample , we should use the API like that . I think that requesting permission when there is no permission is a very common situation,so ,if there is a API can do this make user avoid from the inconvenient if else
is more easy to used.
@LeonChen1024 thank you for sending this pull request. In my opinion I don't believe the if/else
form is inconvenient enough to make us add something like autoRequest
. In the future please open an issue before sending a PR for a new feature so that we can discuss it and save you time!
Thanks again for sending such a well-formed PR though! Hope you understand the decision.
Thanks , I think i understand that , Sorry for wasting your time and never happen this mistake again.
@LeonChen1024 Don't worry about it! 😊 BTW, here's what I meant when I said this already existed:
public void start() {
// This will call the annotation processor immediately if the permissions are granted, else request them
EasyPermissions.requestPermissions(
this,
getString(R.string.rationale_location_contacts),
RC_LOCATION_CONTACTS_PERM,
LOCATION_AND_CONTACTS);
}
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
public void locationAndContactsTask() {
Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show();
}
@LeonChen1024 definitely not a waste of our time! It was an interesting proposal
as usually if app don't have permission we need to request permission,so this API will easy to use.