title: Android Job Scheduler not running with screen off
body: <p>I'm trying to make a background job that runs periodically and needs to connect to the network. I'm scheduling the job using the JobScheduler service in this way:</p>
  
  <pre><code>JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
  
      if(js!=null) {
          if (js.getAllPendingJobs().size() == 0) {//No jobs scheduled in previous boots. Schedule one
              JobInfo.Builder b = new JobInfo.Builder(1, new ComponentName("my.app.name", MyJob.class.getName()));
              b.setPeriodic(420000);
              b.setPersisted(true);
              b.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
  
              js.schedule(b.build());
          }
      }
  </code></pre>
  
  <p>The Job runs correctly when the screen is on, but as soon as it goes off it is not run anymore until it is turned on again (and then it starts immediately).
  I'm guessing that it doesn't run because while the device is idle there is no network connection (even if I checked that the device Wi-Fi and 3G options say to keep connection active while idle).</p>
  
  <p>How can I make my service run even when the device is idle/screen is off?</p>