Android 安全异常 : Admin does not own the profile

标签 android android-activity android-5.0-lollipop android-securityexception

我有一个设备管理器应用程序,我正在尝试使用自 API 21 以来可用的 DevicePolicyManager 类的 setScreenCaptureDisabled(..) 函数。

DevicePolicyManager pManager = (android.app.admin.DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
pManager.setScreenCaptureDisabled(admin.getReceiverName(), true);

我收到以下错误:

03-30 13:50:24.623: E/AndroidRuntime(11564): 
java.lang.SecurityException: Admin 
ComponentInfo{com.example.xxv/com.example.xxv.DeviceAdminReceiver} 
does not own the profile

知道如何解决这个问题吗?

如果需要任何权限,请说明是什么。

最佳答案

您的应用需要成为设备所有者或配置文件所有者。对一台设备执行此操作的最简单方法是使用 adb,如下所示:

http://florent-dupont.blogspot.co.uk/2015/01/android-shell-command-dpm-device-policy.html

基本上来自命令提示符

adb shell 
dpm set-device-owner com.foo.deviceowner/.DeviceAdminRcvr

com.foo.deviceowner 是您的应用包,DeviceAdminRcvr 是您包中的 DeviceAdminReceiver。请注意,您将收到 java.lang.IllegalStateException,除非您已从设备中删除所有帐户(Settings > Accounts)。

另一种方法是创建一个 NFC 配置应用程序:

https://source.android.com/devices/tech/admin/provision.html

关于Android 安全异常 : Admin does not own the profile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29346378/

相关文章:

java - ListView 和 ArrayAdapter 配置,android 应用程序

javascript - 如何在android 5.0( Lollipop )中显示数字键盘

android - 如何检测SD卡上是否添加了新文件(Android)

java - Android View getWidth方法总是返回0

android - 如何在不暂停的情况下将 Activity move 到android中的后台?

java - 将信息备份到文件的 Activity 生命周期

android - 如何在 Android "L"上获取最近的任务?

java - 在新的 Android 5.0 中,方法 TextView.getTextColor(Context context, TypedArray typedArray, int defStyle) 在哪里消失了?

Android:如何让功能等待另一个?

android - 对 FCM 服务器的 POST-ing JSON 请求不起作用