Android应用程序启动时如何激活DeviceAdmin?
您好,我想在应用程序启动时启动/激活设备管理而不使用 Intent。现在我正在使用这段代码:
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, Global.mDeviceAdminSample);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Additional text explaining why this needs to be added.");
startActivityForResult(intent, RESULT_ENABLE);
但我不想使用Intent。我想直接启动设备管理。
谁能知道我该怎么做?
谢谢。
Hello I want to start/activate Device Admin when application start without using Intent. Now I am using this code:
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, Global.mDeviceAdminSample);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Additional text explaining why this needs to be added.");
startActivityForResult(intent, RESULT_ENABLE);
But I dont want to use Intent. I want to start Device Admin directly .
Can anyone know how can I do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
幸运的是,如果没有用户交互,这是不可能的。
用户必须在设置中确认您的应用程序为设备管理员,以便您最多可以将用户导航到设置。
如果应用程序可以在没有用户交互的情况下激活设备管理员(设备管理员拥有相当大的权限),这将是一个巨大的安全风险。
Fortunately it's not possible without user interaction.
User must confirm your app as device admin in settings so you can navigate user to the settings at best.
It would be a huge security risk if apps could activate device administrators without user interaction (device admin has pretty big privileges).
可以通过以下方式实现:
1) 使用 add shell 命令:
2) 以编程方式:
使用 Android 6.0 进行测试。无需root。
大卫
It's doable through the following ways:
1) Using add shell command:
2) Programmatically:
Tested with Android 6.0. No root needed.
David
=>我可以向 android 5.1 授予权限,但无法向 6.0 及以上版本授予权限
=> I can grant permissions to android 5.1 but can't do it with version 6.0 and above