如何以编程方式检查 MIUI 自动启动权限? [英] How to check MIUI autostart permission programmatically?

查看:36
本文介绍了如何以编程方式检查 MIUI 自动启动权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式检查我的应用程序在 MIUI 手机中的自动启动权限是打开还是关闭.Facebook 和 whatsapp 已默认启用此权限,我该怎么做?

I need to check programmatically if the auto start permission for my app in MIUI phone is on or off. Facebook and whatsapp have this permission already enabled by default , how can I do so?

推荐答案

目前不可能.

因为这完全取决于他们的操作系统 API 和自定义.甚至开发者也在小米的官方论坛上提出要求,但那里没有任何回应.

As it's completely depend on their operating system API's and customisation. Even developers have requested for this on XIOMI's official forums but there is no response from there side.

直到现在我都在寻找这个问题的答案,但没有任何帮助.

Till now even i am finding an answer to this question but nothing helped me.

目前只有root手机才有可能.即通过成为超级用户在他们的固件中进行定制.但这一点也不可取,因为它可能会损坏用户的手机.

For the time being it will be only possible for rooted phones. i.e. making customisation in their firmware by becoming super user. But this is not at all advisable as it may damage user's phone.

编辑 1

您可以使用以下代码将用户重定向到自动启动权限的设置页面以启用您的应用

You can redirect user to autostart permission's settings page for enabling your app using following code

String manufacturer = "xiaomi";
if (manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
    //this will open auto start screen where user can enable permission for your app
    Intent intent1 = new Intent();
    intent1.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
    startActivity(intent1);
}

编辑 2我最近使用了小米的 Mi A1,它有库存的 android(不是 miui),所以这款手机没有 miui 的 autostart permission 设置.因此在将用户导航到此类设备中的设置时要小心,因为它在这里不起作用.

EDIT 2 I have recently used Mi A1 from XIOMI which have stock android (not miui) so this phone does not have autostart permission settings from miui. So take care while navigating user to the settings in such devices because it will not work here.

这篇关于如何以编程方式检查 MIUI 自动启动权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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