AlarmManager在多个设备中不起作用 [英] AlarmManager not working in several devices

查看:116
本文介绍了AlarmManager在多个设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用AlarmManager,并且自4年前就开始运行。但是我注意到某些设备开始出现故障。

My app uses AlarmManager and it has been working since 4 years ago. But I noticed it started failing in some devices.

我很确定代码是正确的(我正在将WakefulBroadcastReceiver和setExactAndAllowWhileIdle用于带有Doze的设备),因为它在Nexus设备上运行良好,但在设备上运行失败例如,某些制造商(华为,小米...)。

I'm pretty sure code is right (I'm using WakefulBroadcastReceiver, and setExactAndAllowWhileIdle for devices with Doze) because it's working perfectly on Nexus devices, but it fails in devices of some manufacturers (Huawei, Xiaomi...).

华为设备具有一种可以杀死应用程序的电池管理器,而当某个应用程序被杀死时,计划的警报已取消。因此,在华为电池管理器中将应用设置为受保护即可解决该问题。

Huawei devices, for example, have a kind of battery manager that kill apps, and when an app is killed, scheduled alarms are cancelled. So setting an app as "protected" in Huawei battery manager solves the problem.

但是最近我注意到它不能在更多设备上使用:小米,三星(也许与新的智能管理器有关?)……似乎这种行为正在成为一种标准:杀死后台应用程序。

But recently I noticed it's not working with more devices: Xiaomi, Samsung (maybe it's related to the new "Smart Manager"?)... It seems that this behavior is becoming a standard: to kill background apps.

有人知道吗?是否可以确保发出警报?

Anyone know anything about it? Any way to ensure alarm is fired?

编辑:此问题是由不同制造商添加的省电工具引起的。此处提供更多信息: https://dontkillmyapp.com/

This problem is caused by "battery savers" added by different manufacturers. More info here: https://dontkillmyapp.com/

推荐答案

我已经尝试好几个星期了。我什么都没找到。华为会在一段时间后杀死所有警报。如果我将应用程序放到电池保护程序中受保护的应用程序中,则无济于事。 但是,如果我将应用的程序包名称更改为包含闹钟,时钟或日历之类的字词,则该程序在其他设备上的运行方式绝对正常。。我不知道Google如何为此垃圾提供认证。我认为OEM不应以这种方式修改核心平台。我了解他们有自己的连击保护程序,当用户不使用该应用程序后,它们会在一段时间后将其杀死。但这也会杀死受保护应用程序的警报。

I'm trying to solve it several weeks already. I found nothing. Huawei just kill all the alarms after some time. If I put the app to the protected app in their battery saver it does't help. But If I change package name of my app to contain words like alarm, clock or calendar, it works absolutely normal like on any other devices. I don't understand how Google can give certification for this crap. I think that OEM should not modify core platform in such way. I understand that they have own batter saver which kill the app after some time, when user don't use it. But this killing alarms also of protected apps.

另外,用于精确定时警报的setAlarmClock()也会有所帮助。

Also setAlarmClock() for exact timing alarms helps. But it is not possible to use this for thinks like widget update.

更新:通过包名称关键字进行保护在当前的华为设备上已不起作用,这是不可能的。在2017年为true。

这篇关于AlarmManager在多个设备中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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