对于我的某些功能应用程序,我需要使用相机,这对于应用程序的核心功能不是必需的,所以我需要指定它是可选的使用相机。因此,在清单我宣布同意如下:Android:通过ADB授予权限
<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"/>
但是当我尝试使用以下命令授予亚行批准它给出了一个错误:
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)。根据亚行documentation,由于权限被声明为可选,因此我应该能够如上所述从adb授予许可。我参考了this,this和this。但是我仍然无法弄清楚它不工作的原因。
非常感谢您的建议和意见。