问题描述
嘿,我有一个问题,我一直在寻找解决方案的几天.
Hey guys I've a question and I have been looking for days to find a solution.
我有一个安装在100多种设备上的android应用. (Android 5.1.1 API22和6.0.1 API 23)
I have an android app which is installed on 100+ devices. (Android 5.1.1 API22 and 6.0.1 API 23)
https://developer.android.com/reference/android/app/admin/package-summary.html
我经历了所有这些参考,但是没有运气:/使用devicePolicyManager时,出现错误:XXXXX应用不是设备所有者.我知道有一种方法可以通过Shell命令(ADB)来获得设备所有者,但是我不能通过usb在所有设备上单独做到这一点.
I went through all these references but no luck :/Using the devicePolicyManager, I get the error: XXXXX App is not the device owner.I know there is a way to get device owner by shell command (ADB), but I can't do that on all the devices individually via usb.
推荐答案
源代码说,'设备所有者只能在未配置的设备上设置,除非它是由"adb"启动的,在这种情况下,如果没有帐户与设备的关联
如果您没有设置任何帐户,则可以使用dpm以编程方式进行设置:
If you don't have any accounts set up, you can set it programmatically using dpm:
try {
Runtime.getRuntime().exec("dpm set-device-owner com.example.deviceowner/.MyDeviceAdminReceiver");
} catch (Exception e) {
Log.e(TAG, "device owner not set");
Log.e(TAG, e.toString());
e.printStackTrace();
}
参考: http://florent-dupont.blogspot .fr/2015/01/android-shell-command-dpm-device-policy.html
这篇关于如何在没有NFC和ADB Shell命令的情况下使我的应用程序设备所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!