android设备所有者,android – 如何使我的应用程序成为设备所有者?

除了NFC以外,实际上还有一种方法是将应用程序设置为设备所有者应用程序。

您可以使用adb shell中的dpm命令行工具。

用法:

usage: dpm [subcommand] [options]

usage: dpm set-device-owner

usage: dpm set-profile-owner

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 / Profile所有者应用程序的/data/system/device_owner.xml下创建一个名为device_owner.xml的新文件。

然后,Android平台正在阅读此文件,以检查哪个应用程序被视为设备所有者或配置文件所有者应用程序。

在根深蒂固的设备上,您可能确实是create this file by yourself,但由于dpm工具正在做,您最好使用它(DRY原则):

例如通过Runtime.exec()命令:

Runtime.getRuntime().exec("dpm set-device-owner com.foo.deviceowner/.DeviceAdminRcvr");

另请注意,只有在用户没有设置帐户(确保在“设置>帐户”中没有设置任何帐户)之前,此工具才有效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值