手机唤醒后,未交付的AlarmManager重复警报会怎样? [英] What happens to undelivered AlarmManager repeating alarms when phone wakes up?

查看:93
本文介绍了手机唤醒后,未交付的AlarmManager重复警报会怎样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我们安排每小时发出一次不精确的重复警报,并带有 AlarmManager.setInexactRepeating ,则该电话在待机状态下等待4小时会发生什么情况,醒了吗?系统是否针对相同的 PendingIntent 连续发送4个警报,还是仅发送一个警报?

If we schedule an inexact repeating alarm with AlarmManager.setInexactRepeating to be fired every hour, for example, what happens if the phone is in standby for 4 hours and then it is woken up? Does the system deliver 4 alarms in a row for the same PendingIntent or does it deliver only a single alarm?

编辑:要更仔细地阅读文档, set(int,long,android.app.PendingIntent)方法文档说: Alarm意向传递时会附带一个名为 Intent.EXTRA_ALARM_COUNT 的int类型的数据,该数据表示此意向广播中已累积了多少过去的警报事件。由于电话处于睡眠状态而无法发送的重复警报可能在发送时计数大于一。
因此,当电话退出待机状态时,只会发送一个警报,并有意向

reading the documentation with more attention, the set(int, long, android.app.PendingIntent) method documentation says: Alarm intents are delivered with a data extra of type int called Intent.EXTRA_ALARM_COUNT that indicates how many past alarm events have been accumulated into this intent broadcast. Recurring alarms that have gone undelivered because the phone was asleep may have a count greater than one when delivered. So, when the phone comes out of standby, only one alarm will be delivered, with an intent extra that contains the number of missed alarms.

推荐答案

要更仔细地阅读文档, set(int ,很长,android.app.PendingIntent)方法文档说:警报意图是通过额外的int类型的数据传递的,该数据类型为int.EXTRA_ALARM_COUNT 表示该意图广播中已经累积了多少过去的警报事件。由于电话处于睡眠状态而无法发送的重复警报可能在发送时计数大于一。
因此,当电话退出待机状态时,只会发送一个警报,并有意向包含错过的警报数。

Reading the documentation with more attention, the set(int, long, android.app.PendingIntent) method documentation says: Alarm intents are delivered with a data extra of type int called Intent.EXTRA_ALARM_COUNT that indicates how many past alarm events have been accumulated into this intent broadcast. Recurring alarms that have gone undelivered because the phone was asleep may have a count greater than one when delivered. So, when the phone comes out of standby, only one alarm will be delivered, with an intent extra that contains the number of missed alarms.

这篇关于手机唤醒后,未交付的AlarmManager重复警报会怎样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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