问题
need some help to set up my perodic job correctly with android-job lib.
I want to start a job once a day and the device is ideling. Additionally the job should start as soon as possible on day. That means in best way the job start at 00:01 AM.
And it's not that solution descriped here!
Is this possible? Can anyone give me a hint for the rigth solution?
Here is my code snippset for a Job once a day if device is idle
mJobId = new JobRequest.Builder(JOBTAG)
.setPeriodic(TimeUnit.HOURS.toMillis(24))
.setPersisted(true)
.setUpdateCurrent(true)
.setRequiresCharging(false)
.setRequiresDeviceIdle(true)
.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED)
.build()
.schedule();
回答1:
The linked helper works, you only need to adjust it to your use case.
Note that version 1.2.0 will contain a helper class, which should make this easier for you.
来源:https://stackoverflow.com/questions/41811893/android-job-periodic-once-a-day-deviceidle-true-as-soon-as-possible