setRepeating AlarmManager和setInexactRepeating的区别

编程入门 行业动态 更新时间:2024-10-12 05:47:43
本文介绍了setRepeating AlarmManager和setInexactRepeating的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

什么是下面的参数:

alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, alarmIntent);

和以下的:

alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, alarmIntent);

有什么区别,以及如何在功能方面两个有什么不同?

What is the difference and also how are the two different in terms of functionality?

推荐答案

两个例子都安排一个重复报警,将发送给定的 alarmIntent 。在这两种情况下,在第一时间将其发送器即刻( calendar.getTimeInMillis()返回的当前的时间)。在这两种情况下,该设备将被唤醒,当报警需要发送(如显然由 AlarmManager.RTC_WAKEUP )。

Both examples schedule a repeating alarm that will send the given alarmIntent. On both cases, the first time it is sent will be immediate (calendar.getTimeInMillis() returns the current time). On both cases, the device will be woken up when the alarm needs to be sent (as evident by AlarmManager.RTC_WAKEUP).

有这些调用的两个差异。比较简单的一种是意图将被发送,每天的第二个电话每15分钟在第一次调用,和(你可以在第三个参数见)。更复杂的差异函数调用自身: setRepeating 将安排对于完全每15分钟第一次报警; setInexactRepeating 将安排第二次报警的约每24小时,这意味着它可能会偏离该区间 - 与功耗更低的优势

There are two differences between these calls. The simpler one is that the intent will be sent every fifteen minutes on the first call, and every day on the second call (as you can see in the third parameter). The more complicated difference is the function call itself: setRepeating will schedule the first alarm for exactly every fifteen minutes; setInexactRepeating will schedule the second alarm for approximately every 24 hours, meaning it might deviate from that interval - with the advantage of consuming less power.

请注意,这已经在19 API,在这两个电话是同义的改变。请参见本指南和的这个API文档。

Do notice that this has changed in API 19, where these two calls are synonymous. See this guide, and this API documentation.

更多推荐

setRepeating AlarmManager和setInexactRepeating的区别

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

发布评论

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

>www.elefans.com

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