Freigeben über


AlarmManager.SetExact Method

Definition

Overloads

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.

SetExact(AlarmType, Int64, PendingIntent)

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

[Android.Runtime.Register("setExact", "(IJLandroid/app/PendingIntent;)V", "GetSetExact_IJLandroid_app_PendingIntent_Handler")]
[Android.Runtime.RequiresPermission("android.permission.SCHEDULE_EXACT_ALARM")]
public virtual void SetExact (Android.App.AlarmType type, long triggerAtMillis, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setExact", "(IJLandroid/app/PendingIntent;)V", "GetSetExact_IJLandroid_app_PendingIntent_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.SCHEDULE_EXACT_ALARM")>]
abstract member SetExact : Android.App.AlarmType * int64 * Android.App.PendingIntent -> unit
override this.SetExact : 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

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

This method is like #set(int, long, PendingIntent), but does not permit the OS to adjust the delivery time. The alarm will be delivered as nearly as possible to the requested trigger time.

<b>Note:</b> only alarms for which there is a strong demand for exact-time delivery (such as an alarm clock ringing at the requested time) should be scheduled as exact. Applications are strongly discouraged from using exact alarms unnecessarily as they reduce the OS's ability to minimize battery use.

<p class="note"><strong>Note:</strong> Starting with Build.VERSION_CODES#S, apps targeting SDK level 31 or higher need to request the Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM permission to use this API, unless the app is exempt from battery restrictions. The user and the system can revoke this permission via the special app access screen in Settings.

<p class="note"><strong>Note:</strong> Exact alarms should only be used for user-facing features. For more details, see Exact alarm permission.

Java documentation for android.app.AlarmManager.setExact(int, 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.SetRepeating(Android.App.AlarmType%2c+System.Int64%2c+System.Int64%2c+System.Int64)>
  • <xref:Android.App.AlarmManager.SetWindow(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

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

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

[Android.Runtime.Register("setExact", "(IJLjava/lang/String;Landroid/app/AlarmManager$OnAlarmListener;Landroid/os/Handler;)V", "GetSetExact_IJLjava_lang_String_Landroid_app_AlarmManager_OnAlarmListener_Landroid_os_Handler_Handler", ApiSince=24)]
public virtual void SetExact (Android.App.AlarmType type, long triggerAtMillis, string? tag, Android.App.AlarmManager.IOnAlarmListener listener, Android.OS.Handler? targetHandler);
[<Android.Runtime.Register("setExact", "(IJLjava/lang/String;Landroid/app/AlarmManager$OnAlarmListener;Landroid/os/Handler;)V", "GetSetExact_IJLjava_lang_String_Landroid_app_AlarmManager_OnAlarmListener_Landroid_os_Handler_Handler", ApiSince=24)>]
abstract member SetExact : Android.App.AlarmType * int64 * string * Android.App.AlarmManager.IOnAlarmListener * Android.OS.Handler -> unit
override this.SetExact : Android.App.AlarmType * int64 * string * Android.App.AlarmManager.IOnAlarmListener * Android.OS.Handler -> 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).

tag
String
targetHandler
Handler
Attributes

Remarks

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