I've extended JobService as such:
public class MyJobService extends JobService {
@Override
public boolean onStartJob(JobParameters params) {
return false;
}
@Override
public boolean onStopJob(JobParameters params) {
return false;
}
}
The entire class code is highlighted in yellow.
The warning says:
Specify a valid range of job id's for WorkManager to use.
What am I doing wrong and what should I do?
The warning suggests, that as long as an implementation of
JobServiceclass is created then user should be specifying which IDs theWorkManageris eligible to use "in order to not clash job codes used in the rest of your app" (see dosc atsetJobSchedulerJobIdRange(int, int)).This should be done upon creation of
androidx.work.Configurationinstance:Unfortunately, I couldn't make the thing work for my setup and I had to look into the sources of lint (
SpecifyJobSchedulerIdRangeIssueDetector). As I can understand from the logic, as soon as there is a method call tosetJobSchedulerJobIdRange(see line 92) - then the detector will assume that job range id has been specified by the user, but that doesn't work (at least on my machine).Unfortunately, checking the test class for the detector didn't convey anything either.
As for now I can claim that:
JobServicedoesn't result in a lint warningJobServiceresults in a lint warning, but that doesn't get fixed even whensetJobSchedulerJobIdRange()is performed in some other class other than theJobServiceInterestingly, calling
setJobSchedulerJobIdRange()in theJobServiceclass fixes the warning:Apparently, there are some issues with this detector implementation (or on my machine).
Nevertheless, if you've specified the range of IDs that WorkManager is free to use (i.e. you have called
setJobSchedulerJobIdRange()) - then you're good to suppress this warning.