JobProxy.Common.cleanUpOrphanedJob(mContext, request.getJobId());
JobProxy.Common.cleanUpOrphanedJob(mContext, request.getJobId());
/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }
/** * Cancel either the pending {@link JobRequest} or the running {@link Job}. * * @param jobId The unique ID of the {@link JobRequest} or running {@link Job}. * @return {@code true} if a request or job were found and canceled. */ public boolean cancel(int jobId) { // call both methods boolean result = cancelInner(getJobRequest(jobId, true)) | cancelInner(getJob(jobId)); JobProxy.Common.cleanUpOrphanedJob(mContext, jobId); // do this as well, just in case return result; }
/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }
/** * Cancel either the pending {@link JobRequest} or the running {@link Job}. * * @param jobId The unique ID of the {@link JobRequest} or running {@link Job}. * @return {@code true} if a request or job were found and canceled. */ public boolean cancel(int jobId) { // call both methods boolean result = cancelInner(getJobRequest(jobId, true)) | cancelInner(getJob(jobId)); JobProxy.Common.cleanUpOrphanedJob(mContext, jobId); // do this as well, just in case return result; }