AlarmManager Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- 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 android.content.Context#startService 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.
<b>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 android.os.Handler
.</b>
<p class="caution"><strong>Note:</strong> Beginning with API 19 (android.os.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.
Java documentation 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
AlarmManager(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Fields
ActionNextAlarmClockChanged |
Broadcast Action: Sent after the value returned by
|
ActionScheduleExactAlarmPermissionStateChanged |
Broadcast Action: An app is granted the
|
IntervalDay |
Available inexact recurrence interval recognized by
|
IntervalFifteenMinutes |
Available inexact recurrence interval recognized by
|
IntervalHalfDay |
Available inexact recurrence interval recognized by
|
IntervalHalfHour |
Available inexact recurrence interval recognized by
|
IntervalHour |
Available inexact recurrence interval recognized by
|
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
NextAlarmClock |
Gets information about the next alarm clock currently scheduled. |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Methods
Cancel(AlarmManager+IOnAlarmListener) |
Remove any alarm scheduled to be delivered to the given |
Cancel(PendingIntent) |
Remove any alarms with a matching |
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) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
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) | |
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 |
SetExact(AlarmType, Int64, PendingIntent) |
Schedule an alarm to be delivered precisely at the stated time. |
SetExact(AlarmType, Int64, String, AlarmManager+IOnAlarmListener, Handler) |
Schedule an alarm to be delivered precisely at the stated time. |
SetExactAndAllowWhileIdle(AlarmType, Int64, PendingIntent) |
Like |
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. |
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) |
Schedule an alarm to be delivered within a given window of time. |
SetWindow(AlarmType, Int64, Int64, String, IExecutor, AlarmManager+IOnAlarmListener) | |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (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
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |