如何检查是否实际使用了Android权限? [英] How to check if Android Permission is actually being used?

查看:689
本文介绍了如何检查是否实际使用了Android权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在维护一个现有的(非常大,非常敏感的)Android应用程序.
前几天,我收到客户的一封电子邮件,称该应用程序可能正在声明未在积极使用的权限.


I am maintaining one existing (very-huge, very-sensitive) Android Application.
The other day, I have received an email from my client that, the Application might be declaring the Permissions that are not actively being used.

例如,他们希望我删除"WRITE_EXTERNAL_STORAGE"权限.
我已将其删除并编译并运行该应用程序.完全没有错误.
但是,正因为如此,我认为我不能认为根本没有积极地使用许可.

For example, they wants me to remove "WRITE_EXTERNAL_STORAGE" permission.
I have removed it and compiled it and run the App. There is NO error at all.
But, just because of that, I don't think I can assume that permission is not actively being used at all.

我的问题是无论如何,我是否可以轻松轻松地检查许可是否正在被积极使用?"

坦率地说,我不想遍历该应用程序的每个小细节,只是为了弄清楚是否需要许可.
我只是没有时间.

Frankly, I don't want to go through every little detail aspect of that application just to fine out the permission is required or not.
I just don't have time.

我的目标是检查是否正在积极使用权限.如果没有,请删除权限.
希望有一种更省时的方法.

My goal is check if the permission is actively being used. If not, remove the permission.
Hope there is an less-time consuming way for that.

致谢

推荐答案

在Android Studio 1.3和更高版本中; Android支持库v7:22.2.0,您有解决方案.

In Android Studio 1.3 & Android Support Library v7:22.2.0, you have solution for it.

步骤:

  1. 将Android Studio更新到V1.3
  2. 将您的Android支持库更新为v7:22.2.0
  3. 运行Android Lint(分析->检查代码),在Lint Error中,查看类型"Android-> Constant& Resource Type MisMatch",其中显示了所有需要许可的方法.

说明

  1. Android引入了新的批注@requirespermission.
  2. 所有需要许可的SDK方法都用@requirespermission注释.
  3. 当我们调用任何需要许可的sdk方法而没有正确检查我们是否具有许可权时,Android studio会遇到lint错误.

这篇关于如何检查是否实际使用了Android权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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