如何找出Android应用程式需要哪些权限 [英] How to find out which permission an android application needs

查看:115
本文介绍了如何找出Android应用程式需要哪些权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何找出我需要为应用程序清单添加哪些权限?实际上,何时我需要在清单中添加权限,以及如何找出我的应用程序确实需要在清单中添加一些权限,然后才能将其安装在设备上?是否可以从导入的软件包中找出权限?例如,有什么方法可以找出我们需要在清单中添加"uses-permission android:name =" com.android.alarm.permission.SET_ALARM"权限的原因,因为我们添加了" import android.app.AlarmManager;"在代码中?

how can i find out which permissions i need to add in manifest for my applications? Actually, WHEN i need to add permission in manifest and HOW to find out my app really need to add some permissions in manifest before install it on device? is it possible to find out permissions from imported package? for example is there any way to find out we need to add "uses-permission android:name="com.android.alarm.permission.SET_ALARM" permissions in manifest because we add "import android.app.AlarmManager;" in code?

我的大问题是:我的应用程序运行良好,但是当用户将手机升级到新的android时,我的应用程序无法运行,我需要找出清单中丢失了哪些权限. (例如,我们在android 2.2中不需要任何权限来访问SD卡,但是在android 4.0中,我们需要在清单中添加权限).预先感谢

MY BIG PROBLEM IS: my apps work fine, but when users upgrade phones to new android, my apps not work, and i need to find out which permission lost from my manifest. (for example we don't need any permissions for SD card access in android 2.2, but in android 4.0 we need to add permissions in manifest). thanks in advance

推荐答案

如何找出需要为应用程序清单添加哪些权限?

how can i find out which permissions i need to add in manifest for my applications?

有时,权限记录在文档中,例如在JavaDocs中记录了需要这些权限的类和方法.

Sometimes, the permissions are documented, such as in the JavaDocs for classes and methods that need those permissions.

有时,权限记录不充分.您通过测试或遍历其他地方的注释(例如堆栈溢出问题和答案)发现需要它们.

Sometimes, the permissions are not well-documented. You find out that you need them by testing, or by running across notes about them elsewhere, such as Stack Overflow questions and answers.

有时,IDE(例如Android Studio)或构建过程(例如带有Lint检查的Gradle)会在编译时抱怨缺少权限.通常,这些用于已记录的权限要求.话虽这么说,在交付应用程序之前,先进行一次Lint手动检查(Android Studio中为检查代码")是个好主意.

On occasion, an IDE (e.g., Android Studio) or a build process (e.g., Gradle with Lint checks) will complain at compile time about a missing permission. Usually, those are for already-documented permission requirements. That being said, running a manual Lint check ("Inspect Code" in Android Studio) is a good idea before shipping an app.

如何找出我的应用程序确实需要在清单中添加一些权限,然后才能将其安装在设备上?

HOW to find out my app really need to add some permissions in manifest before install it on device?

测试.

是否可以从导入的软件包中找到权限?

is it possible to find out permissions from imported package?

权限通常与Java软件包无关.

Permissions are not usually tied to Java packages.

例如,有什么方法可以找出我们需要在清单中添加"uses-permission android:name ="com.android.alarm.permission.SET_ALARM"权限,因为我们添加了"import android.app.AlarmManager;"在代码中?

for example is there any way to find out we need to add "uses-permission android:name="com.android.alarm.permission.SET_ALARM" permissions in manifest because we add "import android.app.AlarmManager;" in code?

您不需要使用SET_ALARM,因为您正在导入AlarmManager.没有import语句不需要权限.

You do not need to use SET_ALARM because you are importing AlarmManager. No import statement requires a permission.

但是当用户将手机升级到新的android时,我的应用无法正常工作

but when users upgrade phones to new android, my apps not work

当新版本的Android发布时,可以快速对其进行测试.授予您访问开发人员预览的权限时—因为开发人员是Android 5.0和6.0之前的版本-在这些开发人员预览上进行测试.

Quickly test your apps on new versions of Android as those versions are released. When you are given access to developer previews — as developers were prior to Android 5.0 and 6.0 — test on those developer previews.

这篇关于如何找出Android应用程式需要哪些权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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