Android - 如何在小米设备中以编程方式启用自动启动选项? [英] Android - How to Enable Autostart option programmatically in Xiaomi devices?

查看:25
本文介绍了Android - 如何在小米设备中以编程方式启用自动启动选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Android 应用程序,我想在其中显示推送通知.

I am developing an android application in which I want to display the Push notification.

它在除小米手机(我使用的是红米 Note 4)之外的大多数设备上都表现良好.我发现的问题是,这是因为小米提供的 Autostart 选项默认是禁用的,用户需要手动启用.

It has displayed well in most of the devices except Xiaomi phones (I am using Redmi Note 4). The problem that I found is, it is because of Autostart option provided by Xiomi which will be disabled by default and the user need to enable it manually.

但我想知道我能看到的一些 Android 应用程序在没有任何用户交互的情况下启用了此选项,例如:WhatsApp.如果我尝试重新安装 WhatsApp 并看到自动启动选项,则它已启用!

But I wonder that some of the Android Apps I could see enabling this option without any user interaction Ex: WhatsApp. If I try reinstalling WhatsApp and see the Autostart option , it is enabled!

我无法说服我们的客户说这是 Xiomi 之类设备的功能,因为他指出一些应用程序运行良好,就像我上面提到的例子一样.

I am unable to convince our client by telling it is the feature of Xiomi like devices as he is pointing out some apps which is working fine like the example I have mentioned above.

这个问题已经被其他人问过

This question has been asked by some other people

将我的应用添加到 android 中的自动启动应用列表以编程方式

如何以编程方式检查我们的应用程序在小米制造商移动设备中是否启用了自动启动

但我看不到他们的任何答案,并在此处发帖,希望有人对此有答案.

But I could not see any answers for them and Posting here with the hope that someone will have an answer for this.

推荐答案

如果小米操作系统需要,当您从 Playstore 下载应用程序时,自动启动功能将自动启用,因为亚马逊、谷歌 IO 等应用程序也不允许自动启动,在这种情况下,您必须转到安全权限 -> 自动启动 -> 然后从那里启用自动启动.您不能通过代码使应用程序自动启动,您所能做的就是显示一个对话框以启用自动启动并让用户进入自动启动活动,但这不是一个好的选择,因为您无法检查是否启用了自动启动.这是 Mi 在 MIUI8 中为节省电池而完成的.这个问题浪费了我 2 天的时间 XD

The autostart feature will get enabled automatically when you will download the app from playstore if xiaomi OS wants it as apps like amazon ,google IO etc are also not allowed to autostart ,In this case you have to go to Security permissions -> autostart -> then enable autostart from there.You cannot make the app autostart by code all you can do is you can show a dialog to enable auto start and take the user to the autostart activity but this is not a good option as you cannot check whether autostart is enabled or not. This is done by Mi in MIUI8 for saving battery .This issue wasted my 2 days XD

您可以参考这篇文章.

这篇关于Android - 如何在小米设备中以编程方式启用自动启动选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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