Share via


AlarmManager.SetInexactRepeating Method

Definition

Schedule a repeating alarm that has inexact trigger time requirements; for example, an alarm that repeats every hour, but not necessarily at the top of every hour.

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

Parameters

type
AlarmType

type of alarm.

triggerAtMillis
Int64

time in milliseconds that the alarm should first go off, using the appropriate clock (depending on the alarm type). This is inexact: the alarm will not fire before this time, but there may be a delay of almost an entire alarm interval before the first invocation of the alarm.

intervalMillis
Int64

interval in milliseconds between subsequent repeats of the alarm. Prior to API 19, if this is one of INTERVAL_FIFTEEN_MINUTES, INTERVAL_HALF_HOUR, INTERVAL_HOUR, INTERVAL_HALF_DAY, or INTERVAL_DAY then the alarm will be phase-aligned with other alarms to reduce the number of wakeups. Otherwise, the alarm will be set as though the application had called #setRepeating. As of API 19, all repeating alarms will be inexact and subject to batching with other alarms regardless of their stated repeat interval.

operation
PendingIntent

Action to perform when the alarm goes off; typically comes from PendingIntent#getBroadcast IntentSender.getBroadcast().

Attributes

Remarks

Schedule a repeating alarm that has inexact trigger time requirements; for example, an alarm that repeats every hour, but not necessarily at the top of every hour. These alarms are more power-efficient than the strict recurrences traditionally supplied by #setRepeating, since the system can adjust alarms' delivery times to cause them to fire simultaneously, avoiding waking the device from sleep more than necessary.

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 one-shot alarms with an appropriate window instead; see #setWindow(int, long, long, PendingIntent) and #setExact(int, long, PendingIntent).

<p class="note"> As of API 19, all repeating alarms are inexact. Because this method has been available since API 3, your application can safely call it and be assured that it will get similar behavior on both current and older versions of Android.

Apps targeting Build.VERSION_CODES#S will need to set the flag PendingIntent#FLAG_MUTABLE on the PendingIntent being used to set this alarm, if they want the alarm count to be supplied with the key Intent#EXTRA_ALARM_COUNT.

Java documentation for android.app.AlarmManager.setInexactRepeating(int, long, long, android.app.PendingIntent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also