Android-将targetSdkVersion设置为22以避免运行时权限,潜在的问题是什么? [英] Android - set targetSdkVersion to 22 to avoid runtime permissions, what are the potential problems?

查看:842
本文介绍了Android-将targetSdkVersion设置为22以避免运行时权限,潜在的问题是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以总结一下将targetSdkVersion设置为22以避免处理运行时权限的弊端吗?

Can somebody summarize the drawbacks to setting the targetSdkVersion to 22 to avoid handling runtime permissions?

在阅读有关此文档的Google文档以及其他一些Stack Overflow帖子之后,我唯一发现的缺点是用户可以在安装时授予权限,然后进入其操作系统设置并撤消该特定应用程序的特定权限. ,然后再次运行该应用程序.但是,从一些示例中,我发现用代码处理这一点都不困难.

After reading the Google docs on this and a few other Stack Overflow posts, the only downside I can find is that a user could grant permission at install time, then go into their OS settings and revoke that specific permission for that specific app, and then run the app again. However from a few of the examples I found this is not difficult at all to deal with in code.

这真的是使用targetSdkVersion 22在安装时强制许可的唯一缺点吗?事情会在未来几年保持这种状态吗?

Is this really the only drawback to using targetSdkVersion 22 to force permissions at install time? Will things stay this way for years into the future?

此外,例如,如果我在build.gradle文件中使用以下设置:

Also, if for example I use these settings in my build.gradle file:

compileSdkVersion 24
buildToolsVersion "24.0.1"
minSdkVersion 19
targetSdkVersion 22

我是否仍可以访问API 23&一个应用程序中有24个功能,还是我限于22个或更早版本?

Can I still access API 23 & 24 features in an app or am I limited to 22 and earlier?

在有人回应最佳做法是不这样做,并根据Google的建议在运行时根据需要请求权限"之前,是的,我当然知道这一点.是的,我也知道那里的一些示例,这些示例试图提供样板代码以请求运行时权限,例如:

Before somebody responds with "It is best practice to not do this and to request permissions at runtime as needed as recommended by Google", yes, of course I'm aware of this. And yes, I'm also aware of some examples out there that attempt to provide boiler plate code to for ask for runtime permissions such as:

https://github.com/googlesamples/easypermissions

但是,至少有两种情况可以让我想到在安装时请求权限并且如果未授予权限就不安装应用程序的优势:

However there are at least two situations I can think of where it would be very advantageous to request permissions at install time and not install the app if the permissions are not granted:

1)假设工作周中途我向其报告的人问道:您能为XYZ周五会议的会议收集概念验证Android应用吗?如果我必须将一个应用程序的快速Alpha版放在一起,而我只有几天的时间来做,那么将基本功能放在一起将花费很长时间,并且该应用程序将需要4​​个权限,例如最好在安装时要求Alpha版的所有权限,因此我有时间花在应用程序功能上.然后,如果我继续进行,则将应用程序移至Beta版本,然后移至最终版本,以根据需要在运行时将权限请求一一更改.

1) Suppose half way through the work week the person I report to asks "Can you throw together a proof of concept Android app for the Friday meeting that does XYZ to show some visitors we are having that day?" If I have to throw together a quick alpha version of an app and I only have a few days to do it, and it will take that long to put together the basic functionality, and the app will require, say, 4 permissions, it would be much better to demand all permissions at install time for the alpha version so I have the time to spend on the app functionality. Then if I get the go ahead, as I move the app to beta and then to final, to change permission requests to one by one at run time as needed.

2)某些应用程序绝对需要某些权限才能使用.例如,如果我正在编写一个OpenCV应用程序,该应用程序从摄像机中获取图像,然后根据图像中的内容进行某些操作,则最好不要让这样的应用程序从用户开始安装不愿意授予摄像头许可.

2) Some apps absolutely need certain permissions to be of any use. For example, if I'm writing an OpenCV app that takes images from the camera and then does something based on what is or is not in the images, it would be preferable to not let such an app be installed to begin with if the user is not willing to grant camera permission.

我真的希望Google保留它作为安装时请求/获取权限的选项,并且还提供了在运行时请求权限的选项.对于只能在运行时请求权限的决定,开发人员是否有负面反馈? Google是否有可能在安装版本或运行版本的将来版本中允许权限请求,在这种情况下,我可以在此期间简单地使用targetSdkVersion 22选项?

I really wish Google had left it in as an option to request/require permissions at install time, and also offer the option to request permissions at runtime. Has there been any negative developer feedback regarding the decision to be able to ask for permissions at runtime only? Is it possible that Google may allow permission requests at install time or run time in a future version, in which case I could simply use the targetSdkVersion 22 option in the interim?

推荐答案

这真的是使用targetSdkVersion 22在安装时强制许可的唯一缺点吗?

Is this really the only drawback to using targetSdkVersion 22 to force permissions at install time?

不.例如,除非您的targetSdkVersion为24或更高版本,否则在尝试以分屏模式使用应用程序时,Android 7.0+设备用户将获得此应用程序可能不支持分屏显示" Toast.

No. For example, unless your targetSdkVersion is 24 or higher, Android 7.0+ device users will get a "this app may not support split-screen" Toast when trying to use your app in split-screen mode.

此外,关于运行时权限,请记住,targetSdkVersion为22或更低意味着在安装时将提示用户输入所有您请求的权限.您似乎认为这是肯定的.潜在的用户可能会不同意.在需要在安装时请求各种权限的App A和没有请求的App B之间进行选择的情况下,用户会倾向于选择App B,而没有使用App A的强烈理由.随着时间的流逝,随着Android 6.0及更高版本的推出,越来越多的用户,在安装时请求权限的应用将被视为未维护或编写不正确,因为用户期望不必事先同意权限.

Also, with respect to runtime permissions, bear in mind that a targetSdkVersion of 22 or lower means that the user will be prompted for all your requested permissions at install time. You appear view this as a positive. Prospective users may disagree. Given a choice between App A which requests all sorts of permissions at install time and App B that does not, users will tend to choose App B, absent strong reasons to go with App A. Over time, as Android 6.0+ rolls out to more and more users, apps that request permissions at install time will be viewed as unmaintained or poorly written, as users will expect not to have to agree to permissions up front.

事情会在未来几年内保持这种状态吗?

Will things stay this way for years into the future?

否.

我是否仍可以访问API 23&应用中的24个功能

Can I still access API 23 & 24 features in an app

是的,尽管由于您的targetSdkVersion某些行为可能有所不同.

Yes, though some may behave differently due to your targetSdkVersion.

Google是否有可能在安装时或将来版本的运行时允许权限请求

Is it possible that Google may allow permission requests at install time or run time in a future version

一切皆有可能.一般来说,Google不会讨论这样的未来计划.

Anything is possible. In general, Google does not discuss future plans like this.

这篇关于Android-将targetSdkVersion设置为22以避免运行时权限,潜在的问题是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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