Android 当管理员不允许更改时请求权限

Android RequestPermission when administrator does not allow them to be changed

我有一个场景,其中 android 应用权限由管理员通过 MDM 设置,设备用户无法更改。

如果检查权限后拒绝权限会发生什么。然后代码请求权限,用户选择允许权限。

如果管理员将权限设置为被拒绝会怎样?

是否会通过另一个对话框自动通知用户?

onRequestPermissionsResult 是否会在传递的 grantResults 数组中声明权限被拒绝?

或者是否发生了其他事情。我没有可以测试它的设置。希望有人能解释这种情况的结果

根据 Explain why the app needs permission documentation:

One approach you might use is to provide an explanation only if the user has already denied that permission request. Android provides a utility method, shouldShowRequestPermissionRationale(), that returns true if the user has previously denied the request, and returns false if a user has denied a permission and selected the Don't ask again option in the permission request dialog, or if a device policy prohibits the permission.

因此,如果您请求权限,权限将立即被拒绝——用户不会看到任何权限提示。如果 shouldShowrequestPermissionRationale() returns 为 false,则 用户 已永久拒绝您的许可,或者 设备策略 已永久拒绝您的许可.