Share via


AlarmManager.SetWindow Method

Definition

Overloads

SetWindow(AlarmType, Int64, Int64, PendingIntent)

Schedule an alarm to be delivered within a given window of time.

SetWindow(AlarmType, Int64, Int64, String, AlarmManager+IOnAlarmListener, Handler)

Schedule an alarm to be delivered within a given window of time.

SetWindow(AlarmType, Int64, Int64, String, IExecutor, AlarmManager+IOnAlarmListener)

SetWindow(AlarmType, Int64, Int64, PendingIntent)

Schedule an alarm to be delivered within a given window of time.

[Android.Runtime.Register("setWindow", "(IJJLandroid/app/PendingIntent;)V", "GetSetWindow_IJJLandroid_app_PendingIntent_Handler")]
public virtual void SetWindow (Android.App.AlarmType type, long windowStartMillis, long windowLengthMillis, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setWindow", "(IJJLandroid/app/PendingIntent;)V", "GetSetWindow_IJJLandroid_app_PendingIntent_Handler")>]
abstract member SetWindow : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit
override this.SetWindow : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit

Parameters

type
AlarmType

type of alarm.

windowStartMillis
Int64

The earliest time, in milliseconds, that the alarm should be delivered, expressed in the appropriate clock's units (depending on the alarm type).

windowLengthMillis
Int64

The length of the requested delivery window, in milliseconds. The alarm will be delivered no later than this many milliseconds after windowStartMillis. Note that this parameter is a duration, not the timestamp of the end of the window.

operation
PendingIntent

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

Attributes

Remarks

Schedule an alarm to be delivered within a given window of time. This method is similar to #set(int, long, PendingIntent), but allows the application to precisely control the degree to which its delivery might be adjusted by the OS. This method allows an application to take advantage of the battery optimizations that arise from delivery batching even when it has modest timeliness requirements for its alarms.

Note: Starting with API Build.VERSION_CODES#S, apps should not pass in a window of less than 10 minutes. The system will try its best to accommodate smaller windows if the alarm is supposed to fire in the near future, but there are no guarantees and the app should expect any window smaller than 10 minutes to get elongated to 10 minutes.

This method can also be used to achieve strict ordering guarantees among multiple alarms by ensuring that the windows requested for each alarm do not intersect.

When precise delivery is not required, applications should use the standard #set(int, long, PendingIntent) method. This will give the OS the most flexibility to minimize wakeups and battery use. For alarms that must be delivered at precisely-specified times with no acceptable variation, applications can use #setExact(int, long, PendingIntent).

Java documentation for android.app.AlarmManager.setWindow(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.

See also

  • <xref:Android.App.AlarmManager.Set(Android.App.AlarmType%2c+System.Int64%2c+System.Int64)>
  • <xref:Android.App.AlarmManager.SetExact(Android.App.AlarmType%2c+System.Int64%2c+System.Int64)>
  • <xref:Android.App.AlarmManager.SetRepeating(Android.App.AlarmType%2c+System.Int64%2c+System.Int64%2c+System.Int64)>
  • Cancel(PendingIntent)
  • SendBroadcast(Intent)
  • <xref:Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver%2c+Android.Content.IntentFilter)>
  • FilterEquals(Intent)

Applies to

SetWindow(AlarmType, Int64, Int64, String, AlarmManager+IOnAlarmListener, Handler)

Schedule an alarm to be delivered within a given window of time.

[Android.Runtime.Register("setWindow", "(IJJLjava/lang/String;Landroid/app/AlarmManager$OnAlarmListener;Landroid/os/Handler;)V", "GetSetWindow_IJJLjava_lang_String_Landroid_app_AlarmManager_OnAlarmListener_Landroid_os_Handler_Handler", ApiSince=24)]
public virtual void SetWindow (Android.App.AlarmType type, long windowStartMillis, long windowLengthMillis, string? tag, Android.App.AlarmManager.IOnAlarmListener listener, Android.OS.Handler? targetHandler);
[<Android.Runtime.Register("setWindow", "(IJJLjava/lang/String;Landroid/app/AlarmManager$OnAlarmListener;Landroid/os/Handler;)V", "GetSetWindow_IJJLjava_lang_String_Landroid_app_AlarmManager_OnAlarmListener_Landroid_os_Handler_Handler", ApiSince=24)>]
abstract member SetWindow : Android.App.AlarmType * int64 * int64 * string * Android.App.AlarmManager.IOnAlarmListener * Android.OS.Handler -> unit
override this.SetWindow : Android.App.AlarmType * int64 * int64 * string * Android.App.AlarmManager.IOnAlarmListener * Android.OS.Handler -> unit

Parameters

type
AlarmType

type of alarm.

windowStartMillis
Int64

The earliest time, in milliseconds, that the alarm should be delivered, expressed in the appropriate clock's units (depending on the alarm type).

windowLengthMillis
Int64

The length of the requested delivery window, in milliseconds. The alarm will be delivered no later than this many milliseconds after windowStartMillis. Note that this parameter is a duration, not the timestamp of the end of the window.

tag
String
targetHandler
Handler
Attributes

Remarks

Java documentation for android.app.AlarmManager.setWindow(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

SetWindow(AlarmType, Int64, Int64, String, IExecutor, AlarmManager+IOnAlarmListener)

[Android.Runtime.Register("setWindow", "(IJJLjava/lang/String;Ljava/util/concurrent/Executor;Landroid/app/AlarmManager$OnAlarmListener;)V", "GetSetWindow_IJJLjava_lang_String_Ljava_util_concurrent_Executor_Landroid_app_AlarmManager_OnAlarmListener_Handler", ApiSince=34)]
public virtual void SetWindow (Android.App.AlarmType type, long windowStartMillis, long windowLengthMillis, string? tag, Java.Util.Concurrent.IExecutor executor, Android.App.AlarmManager.IOnAlarmListener listener);
[<Android.Runtime.Register("setWindow", "(IJJLjava/lang/String;Ljava/util/concurrent/Executor;Landroid/app/AlarmManager$OnAlarmListener;)V", "GetSetWindow_IJJLjava_lang_String_Ljava_util_concurrent_Executor_Landroid_app_AlarmManager_OnAlarmListener_Handler", ApiSince=34)>]
abstract member SetWindow : Android.App.AlarmType * int64 * int64 * string * Java.Util.Concurrent.IExecutor * Android.App.AlarmManager.IOnAlarmListener -> unit
override this.SetWindow : Android.App.AlarmType * int64 * int64 * string * Java.Util.Concurrent.IExecutor * Android.App.AlarmManager.IOnAlarmListener -> unit

Parameters

type
AlarmType
windowStartMillis
Int64
windowLengthMillis
Int64
tag
String
executor
IExecutor
Attributes

Applies to