如何不精确是setInexactRepeating()的AlarmManager? [英] How inexact is setInexactRepeating() for AlarmManager?

查看:671
本文介绍了如何不精确是setInexactRepeating()的AlarmManager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

在<一个href="http://developer.android.com/reference/android/app/AlarmManager.html#setInexactRepeating%28int,%20long,%20long,%20android.app.PendingIntent%29">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.

这篇关于如何不精确是setInexactRepeating()的AlarmManager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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