AlarmManager.SetAlarmClock(AlarmManager+AlarmClockInfo, PendingIntent) Method
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.
Schedule an alarm that represents an alarm clock, which will be used to notify the user when it goes off.
[Android.Runtime.Register("setAlarmClock", "(Landroid/app/AlarmManager$AlarmClockInfo;Landroid/app/PendingIntent;)V", "GetSetAlarmClock_Landroid_app_AlarmManager_AlarmClockInfo_Landroid_app_PendingIntent_Handler")]
[Android.Runtime.RequiresPermission("android.permission.SCHEDULE_EXACT_ALARM")]
public virtual void SetAlarmClock(Android.App.AlarmManager.AlarmClockInfo info, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setAlarmClock", "(Landroid/app/AlarmManager$AlarmClockInfo;Landroid/app/PendingIntent;)V", "GetSetAlarmClock_Landroid_app_AlarmManager_AlarmClockInfo_Landroid_app_PendingIntent_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.SCHEDULE_EXACT_ALARM")>]
abstract member SetAlarmClock : Android.App.AlarmManager.AlarmClockInfo * Android.App.PendingIntent -> unit
override this.SetAlarmClock : Android.App.AlarmManager.AlarmClockInfo * Android.App.PendingIntent -> unit
Parameters
AlarmManager.AlarmClockInfo: This value cannot be null.
- operation
- PendingIntent
PendingIntent: Action to perform when the alarm goes off; typically comes from IntentSender.getBroadcast(). This value cannot be null.
- Attributes
Remarks
Schedule an alarm that represents an alarm clock, which will be used to notify the user when it goes off. The expectation is that when this alarm triggers, the application will further wake up the device to tell the user about the alarm -- turning on the screen, playing a sound, vibrating, etc. As such, the system will typically also use the information supplied here to tell the user about this upcoming alarm if appropriate. Due to the nature of this kind of alarm, similar to setExactAndAllowWhileIdle(int, long, PendingIntent), these alarms will be allowed to trigger even if the system is in a low-power idle (a.k.a. doze) mode. The system may also do some prep-work when it sees that such an alarm coming up, to reduce the amount of background work that could happen if this causes the device to fully wake up -- this is to avoid situations such as a large number of devices having an alarm set at the same time in the morning, all waking up at that time and suddenly swamping the network with pending background work. As such, these types of alarms can be extremely expensive on battery use and should only be used for their intended purpose.
This method is like setExact(int,long,PendingIntent), but implies RTC_WAKEUP. Note: Starting with Build.VERSION_CODES.S, apps targeting SDK level 31 or higher need to request the SCHEDULE_EXACT_ALARM permission to use this API. The user and the system can revoke this permission via the special app access screen in Settings. Note: Exact alarms should only be used for user-facing features. For more details, see Exact alarm permission. Alarms scheduled via this API will be allowed to start a foreground service even if the app is in the background. Requires Manifest.permission.SCHEDULE_EXACT_ALARM
See also:
Android reference for android.app.AlarmManager.setAlarmClock.
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.