何时确切要求运行时权限? [英] When exactly to ask for Runtime Permission?

查看:70
本文介绍了何时确切要求运行时权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为运行时权限是在Android Marshmallow中引入的,我的意思是应用新的方法来请求权限,并且我已经阅读并理解了危险的权限以及如何检查和请求权限.

Since Runtime Permissions were introduced in Android Marshmallow, I've been meaning to apply the new way for requesting permissions and I've read and understood the dangerous permissions and how to check for them and request them.

问题是,如果我有一个Activity包含用于打开Camera的Button. 打开活动后,我是否检查并请求许可?还是单击按钮时?

The question is, If I have an Activity that contains a Button for opening Camera. Do I check and request the permission when the Activity is opened? Or when the button is clicked?

请解释为什么首选您建议的方式.

Please explain why your suggested way is preferred.

推荐答案

打开活动"后,我是否检查并请求许可?还是单击按钮时?

Do I check and request the permission when the Activity is opened? Or when the button is clicked?

如果Activity的唯一目的是在单击按钮时拍照,那么我将在活动打开时请求权限.

If the only purpose of the Activity is to take a picture when the button is clicked, I would request the permission when the activity is opened.

如果Activity还有其他角色,例如拍照"按钮只是众多功能中的一个功能,那么当用户单击该按钮时,我会征求许可.

If the Activity has other roles, such that the take-a-picture button is only one feature out of many, I would ask for the permission when the user clicks the button.

换句话说,一旦用户请求沿着一条(几乎)肯定需要许可的路径,就请求许可.

In other words, once the user has requested to go down a path that will (almost) certainly need the permission, ask for the permission.

这篇关于何时确切要求运行时权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆