是否可以使我的应用程序在安全模式下工作? [英] Is it possible to make my application work in safe mode?

查看:194
本文介绍了是否可以使我的应用程序在安全模式下工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个android应用程序,它分别列出了已安装的应用程序和系统应用程序.当用户尝试从我的应用程序重启设备时,它将打开我的应用程序,而不是默认的家庭启动器.

I have an android application which lists installed and system applications separately. When the user tries to reboot the device from my application it will open my application instead of default home launcher.

但是,当设备重新启动到'safe mode'时,所有逻辑崩溃.即,设备以安全模式重新启动到我的应用程序,但未列出任何已安装的应用程序并停止其工作.

But when the device is rebooted to 'safe mode' all logic crashes .ie, the device rebooted to my application in safe mode but it does not list any installed applications and stops its working.

  1. 是否可以使我的应用程序也可以在'Safe mode'中工作?

是否有任何方法可以像使用RECEIVE_BOOT_COMPLETED broadcastreceiver一样阻止设备在运行应用程序时进入'safe mode'?

Is there any way to prevent the device from going to 'safe mode' while running my application like using a RECEIVE_BOOT_COMPLETED broadcastreceiver?

什么是设备管理应用程序?在这种情况下有帮助吗?

What is device admin applications? Is it helpfull in this situation?

是否可以通过编程方式检测安全模式?

Is it possible to detect safe mode programmatically?

预先感谢

推荐答案

我知道这个问题很古老,但这也许会对某人有所帮助.如果您的应用程序是主要用户的设备所有者"或配置文件所有者",则可以完全禁用安全模式(它无需root用户即可运行):

I know this question is old, but perhaps this will help someone. If your application is Device Owner or Profile Owner on the primary user, you can disable safe mode completely (it works without root):

DevicePolicyManager manager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName admin = new ComponentName(getApplicationContext(), DeviceAdminReceiver.class);
// To disable safe boot
manager.addUserRestriction(admin, UserManager.DISALLOW_SAFE_BOOT);
// To enable safe boot again
// manager.clearUserRestriction(admin, UserManager.DISALLOW_SAFE_BOOT);

您可以仅通过ADB设置设备所有者或配置文件所有者: https ://developer.android.com/studio/command-line/adb#dpm

You can set Device Owner or Profile Owner simply via ADB: https://developer.android.com/studio/command-line/adb#dpm

adb shell dpm set-device-owner com.example.deviceownerapp/.DeviceAdminReceiver

请注意,激活设备所有者时,您必须不添加任何帐户(尽管您不必进行系统重置,只需从设置中删除所有帐户).设置设备所有者后,您可以再次添加任何帐户.

Note that you must have no accounts added when activating device owner (you don't have to do system reset though, just remove all account from settings). After device owner is set, you can add any accounts again.

这篇关于是否可以使我的应用程序在安全模式下工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆