如何不精确是setInexactRepeating()的AlarmManager?不精确、setInexactRepeating、AlarmManager

2023-09-05 08:23:58 作者:时间总嘲笑涐的痴心妄想

所以这里的交易...我有沉默用户的电话时,他们有一流的。所以,我需要警报以每日熄灭在特定的时间,为每个类。

So here's the deal... I've got to silence the user's phone when they have class. So I need an alarm to go off daily at a specific time, for each class.

所以,我想每个班级都有自己的报警(一天的时间间隔设置)。如果类是在会话中的present一天,电话是沉默。

So I'm thinking every class has their own alarm (interval set for a day). And the phone is silenced if class is in session the present day.

下面是我目前的code:

Here's my current code:

am.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTime, 
                       DAY_IN_MILLISECONDS, start);

威尔setInexactRepeating()是足够精确到几分钟过了一天的时间间隔内沉默了电话?

推荐答案

大概不会,特别是如果这是一整天的时间。

Probably not, especially if that's an interval of an entire day.

在documentation:

您报警的第一个触发器会不会要求的时间前,但这可能不会发生,几乎到时候经过整整间隔。此外,虽然重复报警的总体期间将被请求,报警的任何两个连续的点火之间的时间可以变化。如果你的应用需求非常低的抖动,使用setRepeating(INT,很长很长,PendingIntent)来代替。

Your alarm's first trigger will not be before the requested time, but it might not occur for almost a full interval after that time. In addition, while the overall period of the repeating alarm will be as requested, the time between any two successive firings of the alarm may vary. If your application demands very low jitter, use setRepeating(int, long, long, PendingIntent) instead.