According to this document,
to check if you have a permission, call the ContextCompat.checkSelfPermission()
And this document says:
[Context].checkPermission() is to determine whether the given permission is allowed for a particular process and user ID running in the system
I've the following code on android 24:
smsPerm = "android.permission.SEND_SMS";
int result = checkPermission(smsPerm, Process.myPid(), Process.myUid());
the result
would be:
PackageManager.PERMISSION_GRANTED
ifsmsPerm
is added to manifest and is granted on runtime.PackageManager.PERMISSION_DENIED
ifsmsPerm
is added to manifest but is not granted on runtime.PackageManager.PERMISSION_DENIED
ifsmsPerm
is not added to manifest.
With that saying, it seems the behavior is the same as checkSelfPermission
on android +24. Can I use checkPermission
instead of checkSelfPermission
?
from Can I use checkPermission instead of checkSelfPermission on android +24?
No comments:
Post a Comment