Can I use checkPermission (String permName, String pkgName) or something similar inside my application to check other apps granted permissions?
for example If I want to check if app1 which is installed in my device granted android.permission.WRITE_CONTACTS , can I use checkPermission to check that in my app or not ?
I know the new release of marshmallow allow users to revoke some permissions, for that I want to check it
If that is not allowed please suggest alternative method. This more information about checkPermission
PERMISSION_GRANTED is a number. Specifically, it has a value of 0. You cannot use a number to check anything.
You can use checkPermission() on PackageManager to see whether a particular app (identified by its application ID, a.k.a. package name) holds a particular permission. That method returns either PERMISSION_GRANTED or PERMISSION_DENIED.
However, note that on Android 6.0+ devices, if the app you are checking is compiled with a targetSdkVersion of 22 or lower, checkPermission() will return PERMISSION_GRANTED so long as the permission was requested in the manifest (at least for normal and dangerous permissions, which are usually the ones that concern you). While the user can "revoke permissions" from those apps via the Settings app, that status is not reported by checkPermission(), and indeed I know of no way to find out whether the user revoked permissions from an app this way. You may see similar behavior on some custom ROMs that added this sort of permission control mechanism prior to Android 6.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With