I am trying to use the Firebase JobDispatcher to adapt my app to the new Oreo limitations. One of the thing that I need to change is a task that need to be executed when the screen is turned off.
To do that, I am trying to use the contraint DEVICE_IDLE
. In my undestanding, idle means that the device is not currently used, and so the screen should be turned off as a result. Please correct me if Im wrong, I did not manage to find any precise information about this in the Android or Firebase documentations.
So I set my Job like this :
Job myJob = dispatcher.newJobBuilder()
.setService(EclipseLauncher.class)
.setTag(JOB_TAG)
.addConstraint(Constraint.ON_ANY_NETWORK)
.addConstraint(Constraint.DEVICE_IDLE)
.setLifetime(Lifetime.FOREVER)
.setReplaceCurrent(true)
.build();
And this does not work. The idle constraint seems to be completly ignored and the job start immediatly. I tried to add a delayed trigger, and this time the job start as soon as the app goes to the background (when I press the Home button for instance). This is not really what I want.
So is there any way to Job to start a task when the screen is turned off ?