title: Apps may not schedule more than 100 distinct jobs with JobIntentService
body: <p>Here's my <code>JobIntentService</code></p>
  
  <pre><code>public class NotifierService extends JobIntentService {
       public static void enqueueWork(Context context, Intent work) {
           enqueueWork(context, NotifierService.class, JOB_ID, work);
       }
  
       protected void onHandleWork(Intent intent) {
           //simple if/else check
       }
  }
  </code></pre>
  
  <p>However, I got many crashes from the crashlytics which complained about <code>100 distinct jobs</code>:</p>
  
  <pre><code>Caused by java.lang.IllegalStateException: Apps may not schedule more than 100 distinct jobs
     at android.os.Parcel.readException(Parcel.java:1951)
     at android.os.Parcel.readException(Parcel.java:1889)
     at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:211)
  </code></pre>
  
  <p>Is there any reason to solve it?</p>
  
  <p>I had tried to cancel it before enqueuing the new one as below:</p>
  
  <pre><code>if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.LOLLIPOP) {
              JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
              if (scheduler != null) {
                  for (JobInfo jobInfo : scheduler.getAllPendingJobs()) {
                      if (jobInfo.getId() == JOB_ID) {
                          scheduler.cancel(JOB_ID);
                      }
                  }
              }
          }
  </code></pre>
  
  <p>However, I got another issue: </p>
  
  <pre><code>Caused by java.lang.IllegalArgumentException: Given work is not active: JobWorkItem{id=1 intent=Intent { cmp=com.my.test.package/.notifier.NotifierService } dcount=1}
     at android.app.job.JobParameters.completeWork(JobParameters.java:221)
  </code></pre>
  
  <p>Do you guys have any suggestion?</p>
  
  <p>P/s: I could not reproduce it on my devices, but I got it thousand times in CrashReport tool. Canceling work before enqueuing the new work did solve the 100 distinct jobs issue, but it raised another bug as above.</p>