什么是下面的参数:
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的区别
发布评论