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

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

问题描述

我正在开发一个要在其中显示推送"通知的android应用程序.

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

Xiaomi 手机(我正在使用Redmi Note 4)外,它在大多数设备上均显示良好.我发现的问题是因为Xiomi提供了 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中的AutoStart应用列表中以编程方式

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

但是我看不到任何答案,因此希望有人能对此给出答案,在这里发布.

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

推荐答案

如果小米OS希望将其从Playstore下载该应用程序,则该功能会自动启用,因为小米OS希望将其用作亚马逊,谷歌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

您可以参考 查看全文

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