如何在没有NFC和ADB

如何在没有NFC和ADB

本文介绍了如何在没有NFC和ADB Shell命令的情况下使我的应用程序设备所有者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装在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

我浏览了所有这些参考文献,但没有运气.

I went through all these references but no luck.

使用devicePolicyManager时,出现错误:XXXXX应用不是设备所有者.

Using the devicePolicyManager, I get the error: XXXXX App is not the device owner.

我知道有一种方法可以通过Shell命令(ADB)来获得设备所有者,但是我无法通过usb在所有设备上单独做到这一点.

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命令的情况下使我的应用程序设备所有者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 23:56