Flutter android_alarm_manager plugin doesnt run periodically

后端 未结 2 589
甜味超标
甜味超标 2021-01-16 00:34

Im trying to create background timer in Flutter, that will be called every n seconds. Calling AndroidAlarmManager.periodic should run printHello function every 2 seconds, bu

2条回答
  •  梦毁少年i
    2021-01-16 01:09

    You can't schedule an alarm that frequently with AlarmManager:

    Note: Beginning with API 19 (Build.VERSION_CODES.KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int, long, long, android.app.PendingIntent) and setExact(int, long, android.app.PendingIntent). Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested.

    See: https://developer.android.com/reference/android/app/AlarmManager

提交回复
热议问题