语言

AlarmManager.SetRepeating(AlarmType, Int64, Int64, PendingIntent) 方法

定义

计划重复警报。

[Android.Runtime.Register("setRepeating", "(IJJLandroid/app/PendingIntent;)V", "GetSetRepeating_IJJLandroid_app_PendingIntent_Handler")]
public virtual void SetRepeating(Android.App.AlarmType type, long triggerAtMillis, long intervalMillis, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setRepeating", "(IJJLandroid/app/PendingIntent;)V", "GetSetRepeating_IJJLandroid_app_PendingIntent_Handler")>]
abstract member SetRepeating : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit
override this.SetRepeating : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit

参数

type
AlarmType

警报类型。

triggerAtMillis
Int64

使用适当的时钟(具体取决于警报类型),警报应首先关闭的时间(以毫秒为单位)。

intervalMillis
Int64

警报后续重复之间的间隔(以毫秒为单位)。

operation
PendingIntent

警报关闭时要执行的操作;通常来自 PendingIntent#getBroadcast IntentSender.getBroadcast().

特性

注解

计划重复警报。 注意:对于计时操作(时钟周期、超时等),使用处理程序更容易、更高效。 如果已为同一 IntentSender 计划警报,则首先将取消它。 与 set(int、long、PendingIntent)一样,除了还可以提供警报自动重复的时间段。 此警报将继续重复,直到使用 cancel 显式删除(OnAlarmListener)。 如果指定的触发时间过去,警报将立即触发,警报计数取决于过去触发时间相对于重复间隔的距离。 如果警报延迟(例如系统睡眠(例如,对于非_WAKEUP警报类型),将尽快传递跳过的重复。 之后,未来警报将按原计划交付:它们不会随时间而偏移。 例如,如果已设置每小时顶部的定期警报,但手机从 7:45 到 8:45 处于睡眠状态,则一旦电话唤醒,将立即发送警报,则下一个警报将在 9:00 发送。 如果应用程序希望允许传递时间偏移,以确保至少一定时间间隔始终在警报之间运行,则采取方法是使用一次性警报,在处理每个警报传送时自行安排下一个警报。 注意:从 API 19 开始,所有重复的警报都是不精确的。 如果应用程序需要精确的交付时间,则必须使用一次性确切的警报,每次重新安排,如前所述。 目标SdkVersion 早于 API 19 的旧版应用程序将继续具有其所有警报,包括重复警报(视为确切的警报)。 面向Build.VERSION_CODES的应用。如果想要将警报计数与键Intent.EXTRA_ALARM_COUNT一起提供,则 S 需要在用于设置此警报的 PendingIntent 上设置标志PendingIntent.FLAG_MUTABLE。

Android 参考。android.app.AlarmManager.setRepeating

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于

另请参阅