PeriodicWorkRequest not repeating on the tick

Viewed 443

Im setting PeriodicWorkRequest for 15 minutes. But its repeating sometimes 10 sometimes 17 minutes. How can I set max a few seconds deviation.

 val workRequest = PeriodicWorkRequest.Builder(NotificationWork::class.java, 15, TimeUnit.MINUTES).build()
        WorkManager.getInstance().enqueue(workRequest)

13:10

13:26

13:51

14:01

Can I set a background work like an alarm on the tick or else Workmanager work like this always?

My code block is like above.

1 Answers

As Marko said, Precise scheduling is battery in-efficient. WorkManager APIs don't guarentee schedule for that very reason. If you want strict timing, you can take a look at the AlarmManager APIs for that.

Related