AlarmManager.SetAndAllowWhileIdle(AlarmType, Int64, 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.
Like #set(int, long, PendingIntent)
, but this alarm will be allowed to execute
even when the system is in low-power idle (a.
[Android.Runtime.Register("setAndAllowWhileIdle", "(IJLandroid/app/PendingIntent;)V", "GetSetAndAllowWhileIdle_IJLandroid_app_PendingIntent_Handler", ApiSince=23)]
public virtual void SetAndAllowWhileIdle (Android.App.AlarmType type, long triggerAtMillis, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setAndAllowWhileIdle", "(IJLandroid/app/PendingIntent;)V", "GetSetAndAllowWhileIdle_IJLandroid_app_PendingIntent_Handler", ApiSince=23)>]
abstract member SetAndAllowWhileIdle : Android.App.AlarmType * int64 * Android.App.PendingIntent -> unit
override this.SetAndAllowWhileIdle : Android.App.AlarmType * int64 * Android.App.PendingIntent -> unit
Parameters
- type
- AlarmType
type of alarm.
- triggerAtMillis
- Int64
time in milliseconds that the alarm should go off, using the appropriate clock (depending on the alarm type).
- operation
- PendingIntent
Action to perform when the alarm goes off;
typically comes from PendingIntent#getBroadcast
IntentSender.getBroadcast()
.
- Attributes
Remarks
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. doze) modes. This type of alarm must <b>only</b> be used for situations where it is actually required that the alarm go off while in idle -- a reasonable example would be for a calendar notification that should make a sound so the user is aware of it. When the alarm is dispatched, the app will also be added to the system's temporary power exemption list for approximately 10 seconds to allow that application to acquire further wake locks in which to complete its work.</p>
These alarms can significantly impact the power use of the device when idle (and thus cause significant battery blame to the app scheduling them), so they should be used with care. To reduce abuse, there are restrictions on how frequently these alarms will go off for a particular application. Under normal system operation, it will not dispatch these alarms more than about every minute (at which point every such pending alarm is dispatched); when in low-power idle modes this duration may be significantly longer, such as 15 minutes.
Unlike other alarms, the system is free to reschedule this type of alarm to happen out of order with any other alarms, even those from the same app. This will clearly happen when the device is idle (since this alarm can go off while idle, when any other alarms from the app will be held until later), but may also happen even when not idle.
Regardless of the app's target SDK version, this call always allows batching of the alarm.
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.