Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run jobscheduler all the time (doze or not)

How can I run the jobscheduler in doze or non doze mode i.e I want to run the bg job all the time. Is it possible?

JobInfo jobInfo
      = new JobInfo.Builder(MYJOBID, jobService).setPeriodic(15 * 60 * 1000L)
        .setExtras(bundle)
        .setPersisted(true)
        .build();
like image 957
beck Avatar asked Mar 17 '18 03:03

beck


1 Answers

There is tow way to implement what you want.

  1. Use alarm manager with setExactAndAllowWhileIdle() or setAndAllowWhileIdle()

  2. Use WorkManager

I personally suggest you please try with workManager.

like image 165
Dhaval Solanki Avatar answered Oct 17 '22 08:10

Dhaval Solanki