AlarmManager在多个设备中不起作用

编程入门 行业动态 更新时间:2024-10-28 06:29:56
本文介绍了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?

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

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

推荐答案

我已经尝试好几个星期了。我什么都没找到。华为会在一段时间后杀死所有警报。如果我将应用程序放到电池保护程序中受保护的应用程序中,则无济于事。 但是,如果我将应用的程序包名称更改为包含闹钟,时钟或日历之类的字词,则该程序在其他设备上的运行方式绝对正常。。我不知道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在多个设备中不起作用

本文发布于:2023-11-27 05:46:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   中不   设备   AlarmManager

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!