如何在闹钟管理器中设置每天重复闹钟以防止抖动?

问题描述 投票:0回答:1

我想创建一个每日闹钟,定期重复而不中断。我尝试使用 android_alarm_manager 来完成此任务。使用这个,我可以通过在闹钟不再工作后设置一周来创建定期闹钟。我需要每天闹钟,而不仅仅是 7 天

静态未来计划可重复(警报警报)异步{

for (int weekday = 0; weekday < 7; ++weekday) {
  if (alarm.weekday[weekday]) {
    final callbackId = alarm.callbackIdOf(weekday);
    final time = alarm.timeOfDay.toComingDateTimeAt(weekday);

    await _oneShot(callbackId, time);
  
  }
}

}

android flutter android-alarms
1个回答
0
投票
>     static Future scheduleRepeatable(Alarm alarm) async {   final alarmManager = await getSystemService(AlarmManager);   final interval
> = alarm.repeatInterval.inMilliseconds;
> 
>   for (int weekday = 0; weekday < 7; ++weekday) {
>     if (alarm.weekday[weekday]) {
>       final triggerTime = alarm.timeOfDay.toComingDateTimeAt(weekday);
>       await alarmManager.setInexactRepeating(
>         RTC_WAKEUP,
>         triggerTime.millisecondsSinceEpoch,
>         interval,
>         alarm.callbackIdOf(weekday),
>       );
>     }   } }
© www.soinside.com 2019 - 2024. All rights reserved.