How to check all GRANTED permissions for all installed apps whose sdk version is less than 23, like viber

Here is my code please check

List<String> getGrantedPermissions(final String appPackage) {
List<String> granted = new ArrayList<String>();
try {
    PackageInfo pi = getPackageManager().getPackageInfo(appPackage, PackageManager.GET_PERMISSIONS);
    for (int i = 0; i < pi.requestedPermissions.length; i++) {
        if ((pi.requestedPermissionsFlags[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0) {
            granted.add(pi.requestedPermissions[i]);
        }
    }
} catch (Exception e) {
}
return granted;

      

}

It works with installed apps that were using sdk version greater than 23, but app like viber for example shows true even if we turned off app permission

Is there any solution for this please help me here

+3


source to share





All Articles