如何让我的应用程序的设备拥有者? [英] How to make my app a device owner?
问题描述
的<一个href="http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#isDeviceOwnerApp%28java.lang.String%29">device策略管理器API文档和的Android 5.0概述都提到了一些关于设备所有者应用。我如何设置我的应用程序作为的设备所有者的?
The device policy manager API docs and the android 5.0 overview both mention something about a device owner app. How can I setup my app as a device owner?
编辑: 是否有任何其他方式比生根和NFC(如果可用),请分享一下。
Is there any other ways than rooting and NFC if available please share.
推荐答案
实际上,有一种方法比其他NFC和生根将应用程序设置为设备所有者的应用程序。 你可以使用 DPM 命令行工具,从亚行的shell。
There's actually a way other than NFC and rooting to set an application as a device owner app. You could use the dpm command line tool from an adb shell.
用法:
usage: dpm [subcommand] [options]
usage: dpm set-device-owner <COMPONENT>
usage: dpm set-profile-owner <COMPONENT> <USER_ID>
dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
更新:的 DPM
实用程序是非常简单的实际。它的目标是创造下的 /data/system/device_owner.xml 的所谓的新文件的 device_owner.xml 的引用的设备/档案所有者的应用程序。
UPDATE : The dpm
utility is really simple actually. Its goal is to create a new file called device_owner.xml under /data/system/device_owner.xml that references the Device/Profile owner apps.
Android平台,然后读取这个文件来检查哪些应用程序被认为是一个的设备所有者或档案所有者应用的。
The Android platform is then reading this file to check which application is considered as a Device Owner or Profile Owner App.
在一个植根设备,你确实可以<一href="http://stackoverflow.com/questions/21183328/how-to-make-my-app-a-device-owner/27909315#answer-26839548">create该文件自己,但由于 DPM
工具是做什么的,你最好使用它(DRY原则):
On a rooted device, you could indeed create this file by yourself, but since the dpm
tool is doing it, you'd better use it (DRY principle) :
例如通过的Runtime.exec()
命令:
Runtime.getRuntime().exec("dpm set-device-owner com.test.my_device_owner_app");
另请注意,这个工具也是工作只有在不考虑设置为用户(确保没有考虑在设定的设置>帐户的),使用前。
来源和更多信息的的<一个href="http://florent-dupont.blogspot.fr/2015/01/android-shell-command-dpm-device-policy.html">Android shell命令工具:设备策略管理器
这篇关于如何让我的应用程序的设备拥有者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!