android-job: Periodic once a day, DeviceIdle = true, as soon as possible

社会主义新天地 提交于 2019-12-12 01:52:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!