-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add autoRequestPermission() API #216
Conversation
…mission we need to request permission,so this API will easy to use.
|
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). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
|
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. |
@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 |
|
@LeonChen1024 thank you for sending this pull request. In my opinion I don't believe the 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.