AlarmManager.SetRepeating(AlarmType, Int64, Int64, PendingIntent) 方法

定義

排程重複的警示。

[Android.Runtime.Register("setRepeating", "(IJJLandroid/app/PendingIntent;)V", "GetSetRepeating_IJJLandroid_app_PendingIntent_Handler")]
public virtual void SetRepeating (Android.App.AlarmType type, long triggerAtMillis, long intervalMillis, Android.App.PendingIntent operation);
[<Android.Runtime.Register("setRepeating", "(IJJLandroid/app/PendingIntent;)V", "GetSetRepeating_IJJLandroid_app_PendingIntent_Handler")>]
abstract member SetRepeating : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit
override this.SetRepeating : Android.App.AlarmType * int64 * int64 * Android.App.PendingIntent -> unit

參數

type
AlarmType

警示的類型。

triggerAtMillis
Int64

根據警示類型) ,使用適當的時鐘 (,以毫秒為單位的時間。

intervalMillis
Int64

後續警示重複之間的間隔以毫秒為單位。

operation
PendingIntent

當警示關閉時要執行的動作;通常來自 PendingIntent#getBroadcast IntentSender.getBroadcast()

屬性

備註

排程重複的警示。 <b > 注意:針對計時作業 (刻度、逾時等) 使用 android.os.Handler 會比較簡單且更有效率。 </b > 如果已針對相同的 IntentSender 排程警示,則會先取消。

如同 #set ,除了您也可以提供一段時間,警示會自動重複。 此警示會繼續重複,直到使用 #cancel 明確移除為止。 如果指定的觸發程式時間過去,則會立即觸發警示,並依據過去觸發時間與重複間隔的距離而定,觸發程式計數會立即觸發。

例如,如果系統睡眠 (延遲警示,例如,對於非_WAKEUP警示類型) ,則會儘快傳遞略過的重複。 之後,未來將會根據原始排程來傳遞警示;它們不會隨著時間漂移。 例如,如果您已設定每小時頂端的週期性警示,但手機從 7:45 到 8:45 開始睡眠,則會在電話喚醒時立即傳送警示,則下一個警示會在 9:00 傳送。

如果您的應用程式想要允許傳遞時間漂移,以確保在警示之間至少一律經過特定時間間隔,則採取的方法就是使用一次性警示,並在處理每個警示傳遞時自行排程下一個警示。

<p class=「note」 >< b > 注意: < /b > 自 API 19 起,所有重複的警示都是不精確的。 如果您的應用程式需要精確的傳遞時間,則必須使用一次性的確切警示,並依照上述所述每次重新排程。 早于 API 19 的繼承應用程式 targetSdkVersion 會繼續擁有其所有警示,包括重複警示,視為確切。

如果應用程式想要以機碼提供警示計數,則目標 Build.VERSION_CODES#S 應用程式必須在用來設定此警示的 上 PendingIntent 設定旗 PendingIntent#FLAG_MUTABLEIntent#EXTRA_ALARM_COUNT

android.app.AlarmManager.setRepeating(int, long, long, android.app.PendingIntent) JAVA 檔。

此頁面的部分是根據 原始碼專案所建立和共用的工作進行修改,並根據中所述的詞彙使用。

適用於

另請參閱

  • Handler
  • <xref:Android.App.AlarmManager.Set(Android.App.AlarmType%2c+System.Int64%2c+System.Int64)>
  • <xref:Android.App.AlarmManager.SetExact(Android.App.AlarmType%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)