我有一个设备管理器应用程序,我正在尝试使用自 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/