我有一个设备管理器应用程序,我正在尝试使用自 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
where com.foo.deviceowner
是您的应用程序包,并且DeviceAdminRcvr
is the DeviceAdminReceiver
在你的包裹里。请注意,您将得到一个java.lang.IllegalStateException
除非您已从设备中删除所有帐户(Settings
> Accounts
).
另一种方法是创建 NFC 配置应用程序,如下所示:
https://source.android.com/devices/tech/admin/provision.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)