- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在开发一个需要此权限的应用程序:android.permission.MANAGE_USB
。
我知道此权限仅在系统应用程序中授予。
如果我将该应用程序安装为 android 4.1.2 中的系统应用程序,该应用程序可以正常工作。
但是如果我尝试将它作为系统应用程序安装在 android 5.1 中,那么调试日志会打印出我没有权限:
错误:
W/System.err: java.lang.SecurityException:
Neither user 10074 nor current process has android.permission.MANAGE_USB.
有人知道为什么它在 android 5.1 中一直给我这个错误吗?
list :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<uses-permission android:name="android.permission.MANAGE_USB"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_TASKS"/>
<permission android:name="android.permission.SET_TIME"
android:protectionLevel="signatureOrSystem"
/>
<uses-feature android:name="android.hardware.usb.host"
android:required="true"/>
<application
android:name=".services.AppContext"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:hardwareAccelerated="false"
android:theme="@style/AppTheme">
<service android:name=".services.KioskService" android:exported="false"/>
<activity
android:name=".MainActivity"
android:launchMode="singleInstance"
android:stateNotNeeded="true"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.example.app.services.UsbService"
android:enabled="true">
</service>
<receiver android:name=".services.PowerDisconnectReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
</intent-filter>
</receiver>
<receiver android:name=".services.UsbPermissionReceiver">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
</receiver>
</application>
</manifest>
最佳答案
我会尝试将 android:protectionLevel
更改为 signatureOrSystem
:
A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificate as the application that declared the permission. Please avoid using this option, as the signature protection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.
对于签名
:
A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.
我知道您无权访问编译您在设备中使用的 Android 操作系统镜像的任何人使用的签名 key ,因此 signature
protectionLevel
将不匹配并且不授予您权限。
见 https://developer.android.com/guide/topics/manifest/permission-element.html
更新:为了完整起见,我在答案中添加@carlo.S 评论:
In Lollipop, an app to be considered as a system application needs to be installed under the
system/priv-app
folder and notsystem/app
folder like in Android 4.2.2! Also, app needs to have 644 permissions.
当然,设备需要root。
关于java - permission.android.MANAGE_USB 在 Jellybean 中有效,但在 Lollipop OS 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46933771/
我正在开发目标 Sdk 17 的应用程序。我当前的设备是 Nexus 7。 我的应用应该没有操作栏,所以我在 Activity 中使用主题Theme.Holo.NoActionBar。 我想在右下角(
当某些应用程序完成安装或更新时,应用程序的启动器图标与安装通知一起放置,如下所示: 如何让我的应用程序的图标在安装完成时也显示出来? 最佳答案 答案是你不知道。您在此处看到的 Google 日历通知来
我正在为 Jellybean、KitKat 和 Lollipop 以及多种不同的设备开发 Android 应用。 在项目开始时,我使用 Jellybean API 库和目标 API“anroid-18
我有一个带有 RelativeLayout 的应用程序,其中包含一个 ProgressBar 和一个 WebView。没有什么复杂的。但是,我遇到了一个非常奇怪的崩溃,我什至没有看到 ANR 对话框。
所以...我阅读了 jellybean 更新说明并看到“Jelly Bean 为付费应用引入了应用加密。” 据我所知,当有人将其 apk 移动到另一台设备时,此服务应该会使应用程序无法使用。 但是非软
我有一个播放 MP3 文件的应用程序,这些文件可以在公共(public) URL 上找到。不幸的是,服务器不支持流媒体,但 Android 使用户体验相当可以接受。 除 JellyBean 外,它适用
源代码在这里:https://github.com/novemberox/NavigationTest此示例的修改版本:http://developer.android.com/training/im
看起来 Google 已经为第三方应用提供了 Google Now 的离线语音识别功能。 the app named Utter 正在使用它. 有没有人看到过如何使用这个离线语音记录来执行简单的语音命
我刚买了一台新的 lenovo A3500 (A7-50) 平板电脑,带有 4.2.2 jellybean 系统。我的电脑在 widows 8 上运行。当我通过 USB 电缆连接我的平板电脑时,com
我有一个 Android 应用程序,它在引用的库中使用 Gson jar。我目前使用的是 2.2.4 版本,我有 2 部手机来测试它。 在 Samsung Galaxy S Advance 2.3.6
我刚刚将我的 Galaxy Tab2 从 ICS 软件更新到 Jelly Bean。我正在开发一个应用程序,我在其中加载一些带有一些 js 文件的 Html,调用一些用 Javascript 文件编写
我想做的是从我的应用程序调用电话并在此通话中打开扬声器。 在 android 4.0 上一切正常,我只是在开始调用 Intent 之前设置了 audiomanager.setSpeakerphoneO
我发现 2.3.4 和 4.2 之间 onNewIntent 调用的行为有所不同。 我有一个 launchMode=singleTask Activity 。根据我对 singleTask 工作原理的
谁能阐明在 JellyBean [Android] 的服务中引入 Isolatedprocess 标签的真正/主要优势是什么?这在框架级别或内核级别是否有利,正如我们所看到的那样,在服务中将 isol
我制作了一个 XML,其中包含一个 TextView,在以下代码中有一个 textAlignement:center:
我们正在使用 phonegap 3.2.2 开发一个 Android 混合应用程序。 在其中一个 html 页面中,我们正在渲染一个“svg”元素,其中包含 svg 中的“path”元素。每个路径元素
这是我正在使用的代码 Intent i = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTU
Jellybean 键盘有一个奇怪的问题。当我的用户升级他们的操作系统时,每当他们尝试使用键盘输入数据时,它就是无法输入。期间。 这很奇怪,因为您确实可以专注于文本区域,但在键盘上打字却没有输出。 有
我正在使用 JQM 开发一个移动网站,但在为 Android 版本 4 及更高版本设置正文时遇到问题。地址和主题工作。 这是代码。 var shareEmail = "mailto:"+thisAdd
当 ICS 出现时,引入了几个新的扩展宽度字节码。其中大部分是用于支持巨型 ID 的说明。以下是其中一些新指令,取 self 的 ics/dalvik/opcode-gen/bytecode.txt:
我是一名优秀的程序员,十分优秀!