Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PeriodicWorkRequest not repeating on the tick

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.

like image 375
6155031 Avatar asked Jan 14 '19 13:01

6155031


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.

like image 90
Rahul Avatar answered Nov 18 '22 20:11

Rahul