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
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