Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Android Jobsceduler violates constraints API 23

I have this code below but it seems that the jobService gets trigger even when im not online. In later versions this works fine.

            JobScheduler jobScheduler = (JobScheduler)getApplicationContext()
                    .getSystemService(JOB_SCHEDULER_SERVICE);

            ComponentName componentName = new ComponentName(this, MyJob.class);

            JobInfo jobInfo = new JobInfo.Builder(1, componentName)
                    .setRequiredNetworkType(JobInfo.NETWORK_TYPE_CELLULAR)
                    .setPersisted(true).build();

            jobScheduler.schedule(jobInfo);

Comments