title: Handle consecutive events with job scheduler
body: <p>My App must be aware of taking picture by any camera apps on user device and do some progress on that picture.<br>
  On API &lt; 24 i used a broadcast receiver which catches <code>com.android.camera.NEW_PICTURE</code> events and it works fine.<br>
  But according to <a href="https://developer.android.com/reference/android/hardware/Camera.html#ACTION_NEW_PICTURE" rel="nofollow noreferrer">this</a> document to achieve that goal in API >= 24 we must use <code>Job-Scheduler</code> instead.<br>
  I used this code and it works fine for one picture in one job execution time. but when i take consecutive pictures job scheduler only handles first one.<br></p>
  
  <pre><code>@TargetApi(Build.VERSION_CODES.N)
  public class CameraJobService extends JobService
  {
  private static final String TAG = "CameraJobService";
  
  @Override
  public boolean onStartJob(final JobParameters params)
  {
      Log.i(TAG, "onStartJob: " + this);
  
      // do in background thread
      new Thread(() -&gt; {
          doJob(params);
  
          // mark the job as 'finished'
          jobFinished(params, false);
  
          // create a new job
          prepareJob(getApplicationContext());
      }).start();
  
      // mark the job as 'on processing'
      return true;
  }
  
  @Override
  public boolean onStopJob(JobParameters params)
  {
      Log.i(TAG, "onStopJob: " + this);
      // reschedule job if it was terminated by os
      return true;
  }
  
  private void doJob(JobParameters params)
  {
      if (params.getTriggeredContentAuthorities() != null &amp;&amp; params.getTriggeredContentUris() != null)
      {
          //some job here
          Log.d(TAG, "doJob: ");
      }
  }
  
  @TargetApi(Build.VERSION_CODES.N)
  public static void prepareJob(Context context)
  {
      Log.i(TAG, "prepareJob");
      JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
  
      JobInfo.Builder builder = new JobInfo.Builder(1001,
              new ComponentName(context, CameraJobService.class));
  
      builder.addTriggerContentUri(
              new JobInfo.TriggerContentUri(
                      MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                      JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS));
  
      if (scheduler != null)
      {
          scheduler.schedule(builder.build());
      }
  }
  }
  </code></pre>
  
  <p>I initialized my <code>JobService</code> and <code>BroadcastReceiver</code> Here in <code>MainActivity</code>:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      //
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N) {
          // use job scheduler
          CameraJobService.prepareJob(this);
      } else {
          // use broadcast receiver
          CameraBroadcastReceiver.register(this);
      }
  }
  </code></pre>
  
  <p>I think this problem happens because one job is in progress now and we can't start new one before current job be complete. but is there any way to handle this problem?</p>