实际上,除了NFC之外,还有一种方法可以将应用程序设置为设备所有者应用程序。您可以从中使用dpm命令行工具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实用程序实际上非常简单。它的目标是创建一个新的文件device_owner.xml,/data/system/device_owner.xml该文件下引用了设备/配置文件所有者应用。然后,Android平台正在读取此文件,以检查哪个应用程序被视为设备所有者或配置文件所有者应用程序。在有根设备上,您确实可以自己创建此文件,但是由于该dpm工具正在执行此操作,因此最好使用它(DRY原理):例如,通过Runtime.exec()命令:Runtime.getRuntime().exec("dpm set-device-owner com.foo.deviceowner/.DeviceAdminRcvr");另请注意,只有在使用前未为用户设置任何帐户(确保在“设置”>“帐户”中未设置任何帐户)的情况下,此工具才有效。来源和更多信息在Android的shell命令工具:设备规范管理