AlarmManager.SetAndAllowWhileIdle(AlarmType, Int64, PendingIntent) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
像 #set(int, long, PendingIntent),但即使系統處於低功耗閒置狀態(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
參數
- type
- AlarmType
警報類型。
- triggerAtMillis
- Int64
以毫秒計時,使用相應的鬧鐘(視鬧鐘類型而定)。
- operation
- PendingIntent
警報響起時要執行的動作;通常來自 PendingIntent#getBroadcast
IntentSender.getBroadcast()。
- 屬性
備註
類似於 set(int, long, PendingIntent),但即使系統處於低功耗閒置(也稱為休眠)模式,這個警報仍會被允許執行。 這類警報只能用於必須在閒置時觸發警報的情況——一個合理的例子是行事曆通知,應該發出聲音讓使用者能察覺。 警報發出後,應用程式也會被加入系統的臨時電力豁免清單,約 10 秒,讓該應用程式能取得更多喚醒鎖以完成工作。
這些警報在閒置時會大幅影響裝置的電力使用(因此會造成 App 設定的電池問題),因此使用時應謹慎。 為了減少濫用,針對特定應用程式,這些警報的觸發頻率有限制。 在正常系統運作下,這些警報不會超過每分鐘(此時每個待處理的警報都會被發出);在低功耗閒置模式下,這個持續時間可能明顯更長,例如15分鐘。
與其他警報不同,系統可自由重新排程,使其與其他警報(即使是同一應用程式的警報)不同步。 這種情況明顯會在裝置閒置時發生(因為這個鬧鐘可能會在閒置時響起,而其他 App 的鬧鐘會暫時擱置),但即使沒閒置也可能發生。
不論應用程式的目標 SDK 版本為何,這個呼叫總是允許報警的批次處理。
另請參閱:
Android 參考資料。android.app.AlarmManager.setAndAllowWhileIdle
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。