Sunday 24 February 2019

Can I use checkPermission instead of checkSelfPermission on android +24?

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 if smsPerm is added to manifest and is granted on runtime.
  • PackageManager.PERMISSION_DENIED if smsPerm is added to manifest but is not granted on runtime.
  • PackageManager.PERMISSION_DENIED if smsPerm 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