1

有没有办法仅在用户启用某个偏好时才请求特定权限?

就我而言,我可以选择与日历同步以添加日期和设置提醒(据我所知,您无法使用 Intents 在日历中设置提醒)。显然我需要访问日历的权限,但仅当用户启用此选项时。我想,当用户启用首选项时,请求权限,然后在未授予权限时禁用该选项。

4

2 回答 2

2

不。不幸的是,没有选择这样做。

No checks with the user are done while an application is running: it either was granted a particular permission when installed, and can use that feature as desired, or the permission was not granted and any attempt to use the feature will fail without prompting the user.

http://developer.android.com/guide/topics/security/permissions.html

于 2013-04-05T17:15:34.597 回答
1

这是可能的,因为棉花糖。观看视频,展示向 Android Marshmallow 请求许可的最佳做法

您可以在 Android 开发人员指南中找到允许您执行此操作的代码片段,以请求 Marshmallow 及更高版本的权限

于 2018-04-23T18:36:52.897 回答