Reputation: 5984
The JobInfo.Builder has a method for setting device idle state but i am confused as to what it is exactly trying to say.
setRequiresDeviceIdle (boolean requiresDeviceIdle)
Specify that to run, the job needs the device to be in idle mode. This defaults to false.
Idle mode is a loose definition provided by the system, which means that the device is not in use,
and has not been in use for some time. As such, it is a good time to perform resource heavy jobs.
Bear in mind that battery usage will still be attributed to your application, and surfaced to the user in battery stats.
Now the description for the boolean is as follows:
requiresDeviceIdle boolean: Whether or not the device need be within an idle maintenance window.
I basically need the job to fire when the device is not dozing, preferably not even in the maintenance window. The purpose of the job is to download stuff from a network.
Will setting it false cause it to run when the device is not in the maintenance window? ( the actual deep sleep state IDLE and the running state)
will setting it to true cause it to run only in the maintenance windows and in no other cases?
Upvotes: 0
Views: 2574
Reputation: 3574
Setting setRequiresDeviceIdle(true)
will run the scheduled job in the maintenance window of device dozing.
A Maintenance window is a period of dozing(idle state) where all accumulated jobs are given a chance to run for a specific period of time and then the device goes to doze again and then after some time the maintenance window time started and the cycle will be repeated. So when you set true
to setRequiresDeviceIdle()
you job will be executed only in those maintenance windows.
So if you want your job to run at any time(even when the user is using the device) then set setRequiresDeviceIdle()
to false
Upvotes: 2