AlarmManager Class

Definition

This class provides access to the system alarm services.

[Android.Runtime.Register("android/app/AlarmManager", DoNotGenerateAcw=true)]
public class AlarmManager : Java.Lang.Object
[<Android.Runtime.Register("android/app/AlarmManager", DoNotGenerateAcw=true)>]
type AlarmManager = class
    inherit Object
Inheritance
AlarmManager
Attributes

Remarks

This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running. Registered alarms are retained while the device is asleep (and can optionally wake the device up if they go off during that time), but will be cleared if it is turned off and rebooted. The Alarm Manager holds a CPU wake lock as long as the alarm receiver's onReceive() method is executing. This guarantees that the phone will not sleep until you have finished handling the broadcast. Once onReceive() returns, the Alarm Manager releases this wake lock. This means that the phone will in some cases sleep as soon as your onReceive() method completes. If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available. Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler. Note: Beginning with API 19 (Build.VERSION_CODES.KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int,long,long,PendingIntent) and setExact(int,long,PendingIntent). Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested.

Android reference for android.app.AlarmManager.

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.

Constructors

Name Description
AlarmManager(IntPtr, JniHandleOwnership)

Initializes a managed representation of an existing Java Native Interface object.

Fields

Name Description
ActionNextAlarmClockChanged

Broadcast Action: Sent after the value returned by getNextAlarmClock() has changed.

ActionScheduleExactAlarmPermissionStateChanged

Broadcast Action: An app is granted the Manifest.permission.SCHEDULE_EXACT_ALARM permission.

IntervalDay

Available inexact recurrence interval recognized by setInexactRepeating(int,long,long,PendingIntent) when running on Android prior to API 19.

IntervalFifteenMinutes

Available inexact recurrence interval recognized by setInexactRepeating(int,long,long,PendingIntent) when running on Android prior to API 19.

IntervalHalfDay

Available inexact recurrence interval recognized by setInexactRepeating(int,long,long,PendingIntent) when running on Android prior to API 19.

IntervalHalfHour

Available inexact recurrence interval recognized by setInexactRepeating(int,long,long,PendingIntent) when running on Android prior to API 19.

IntervalHour

Available inexact recurrence interval recognized by setInexactRepeating(int,long,long,PendingIntent) when running on Android prior to API 19.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers

Provides JNI binding infrastructure for Android.App.AlarmManager.

NextAlarmClock

Gets information about the next alarm clock currently scheduled.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

Provides JNI binding infrastructure for Android.App.AlarmManager.

ThresholdType

Provides JNI binding infrastructure for Android.App.AlarmManager.

Methods

Name Description
Cancel(AlarmManager+IOnAlarmListener)

Remove any alarm scheduled to be delivered to the given OnAlarmListener.

Cancel(PendingIntent)

Remove any alarms with a matching Intent.

CancelAll()

Remove all alarms previously set by the caller, if any.

CanScheduleExactAlarms()

Called to check if the caller can schedule exact alarms.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FromContext(Context)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Set(AlarmType, Int64, PendingIntent)

Schedule an alarm.

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

Direct callback version of set(int,long,PendingIntent).

SetAlarmClock(AlarmManager+AlarmClockInfo, PendingIntent)

Schedule an alarm that represents an alarm clock, which will be used to notify the user when it goes off.

SetAndAllowWhileIdle(AlarmType, Int64, PendingIntent)

Like set(int,long,PendingIntent), but this alarm will be allowed to execute even when the system is in low-power idle (a.k.a.

SetExact(AlarmType, Int64, PendingIntent)

Schedule an alarm to be delivered precisely at the stated time.

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

Direct callback version of setExact(int,long,PendingIntent).

SetExactAndAllowWhileIdle(AlarmType, Int64, PendingIntent)

Like setExact(int,long,PendingIntent), but this alarm will be allowed to execute even when the system is in low-power idle modes.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetInexactRepeating(AlarmType, Int64, Int64, PendingIntent)

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.

SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
SetRepeating(AlarmType, Int64, Int64, PendingIntent)

Schedule a repeating alarm.

SetTime(Int64)

Set the system wall clock time.

SetTimeZone(String)

Sets the system's persistent default time zone.

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)

Direct callback version of setWindow(int,long,long,PendingIntent).

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

Direct callback version of setWindow(int,long,long,PendingIntent).

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to