The Job Schedular set as follows
ComponentName mServiceComponent = new ComponentName(context, TestJobService.class);
JobInfo.Builder builder = new JobInfo.Builder(jobId, mServiceComponent);
builder.setPeriodic(3 * 60 * 1000);
builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE);
builder.setRequiresDeviceIdle(false);
builder.setRequiresCharging(false);
builder.setPersisted(true);
JobScheduler jobScheduler = (JobScheduler) ChaseForceApplication.getAppContext().getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(builder.build());
The TestJobService class is like this:
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class TestJobService extends JobService {
@Override
public boolean onStartJob(JobParameters params) {
Utility.writeToTheFile(ChaseForceApplication.getAppContext(), "\n\n Job Scheduler StartJob with jobid="+params.getJobId()+" set at " + new Date().toString());
sendBroadcast(new Intent(this, OnSingleAlarmReceiver.class));
return false;
}
@Override
public boolean onStopJob(JobParameters params) {
Log.i(ChaseForceApplication.TAG, "on stop job: " + params.getJobId());
Utility.writeToTheFile(this, "on stop job: " + new Date().toString());
return false;
}
}
It's working on most devices, even in other xiaomi phones but in Xiaomi Redmi 3S it is not working.
Is any setting required for Job Schedular to make it work on that device?
It seems that Xiaomi MIUI operative system don't allow JobScheduler to run https://web.archive.org/web/20171001070316/http://c.mi.com/thread-8779-1-1.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With