【发布时间】:2018-03-21 09:11:27
【问题描述】:
对于我的应用程序的某些功能,我需要使用相机,这不是应用程序的核心功能所必需的,所以我需要指定使用相机是可选的。所以在清单中我声明了如下许可:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
但是当我尝试使用以下命令通过 adb 授予权限时,它会给出错误:
pm grant my.app.package android.permission.CAMERA
给出错误:
Operation not allowed: java.lang.SecurityException: Can't change android.permission.CAMERA. It is required by the application
我的设备是有根的,它运行 android 5.1.1(22)。根据 ADB documentation,由于权限被声明为可选,我应该能够像上面提到的那样从 adb 授予权限。我参考了this、this 和this。但是我仍然无法弄清楚它为什么不起作用的原因。
提前感谢您的建议和建议。
【问题讨论】:
-
可以直接放在你的App代码中吗?
标签: android permissions