Job is not firing on given time...it delays ...delays...delay time increases. my requirement is to perform job no matter what in every 10 mins using Job Scheduler in Android 7.0 and above. here my code snippet
private static long Scheduler_Interval = 5 * DateUtils.MINUTE_IN_MILLIS;
JobScheduler mJobScheduler mJobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(getPackageName(), JobSchedulerService.class.getName()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
builder.setPeriodic(Scheduler_Interval, 1 * DateUtils.MINUTE_IN_MILLIS);
}
builder.setRequiresDeviceIdle(false);
if (mJobScheduler.schedule(builder.build()) <= 0) {
ShowToast("Some error while scheduling the job");
}
public class JobSchedulerService extends JobService {
@Override
public boolean onStartJob(JobParameters jobParameters) {
writeToTestLogFile(GetSavedDateFromLocationProvider()+ "|onStartJob");
return false;
}
@Override
public boolean onStopJob(JobParameters jobParameters) {
writeToTestLogFile(GetSavedDateFromLocationProvider()+ "|onStopJob");
return false;
}
}