android - 以编程方式将包设置为设备所有者
问题描述
我知道命令"adb shell dpm set-device-owner pacakgename"
我想知道是否有一种方法可以在启动后以编程方式询问并设置一个应用程序的设备所有者
基本上与以下相反:
DevicePolicyManager.clearDeviceOwnerApp("com.package.something");
提前致谢!
解决方案
You can only set the device owner if there is no user account on the device, or the device is rooted. This normally means you can only set the device owner immediately after a factory reset. You can set the device owner using NFC provisioning (I've never done this) or in an adb
shell. The adb
method requires the user to enable developer mode, connect the Android device to a computer, and type a command into the shell.
Pseudocode for becoming the device owner:
if the app is not the device owner
if there is a user account
inform the user that the app cannot become the device owner
else if the app is a device administrator
instruct the user to run the adb command
else
request to become a device administrator
My Device Owner app is a complete working example, including how the command that the user must type is generated from the app's package name.
推荐阅读
- python - 如果元素在列表中重复,则从该列表中删除元素
- jquery - 如果特定日期有多个事件,则更改 FullCalendar 的日背景颜色
- c++ - 在 qt5 中连接动态创建的按钮
- flutter - 如何从滑块设置颜色?
- php - 登录后自动重定向,除了 WooCommerce 结帐页面
- c# - 无法使用 C# 删除 cookie
- powerbi - 我无法打开我的 PBIX 文件,ExecuteXmla 结果失败
- google-sheets - 如何引用谷歌表格中的字段?
- android - 使用 Android Studio Artic Fox 安装 MapBox
- asp.net - 警告:Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]