@Override public void cancel(int jobId) { try { getJobScheduler().cancel(jobId); } catch (Exception e) { // https://gist.github.com/vRallev/5d48a4a8e8d05067834e mCat.e(e); } TransientBundleCompat.cancel(mContext, jobId, null); }
@Override public boolean isPlatformJobScheduled(JobRequest request) { List<JobInfo> pendingJobs; try { pendingJobs = getJobScheduler().getAllPendingJobs(); } catch (Exception e) { // it's possible that this throws an exception, see https://gist.github.com/vRallev/a59947dd3932d2642641 mCat.e(e); return false; } //noinspection ConstantConditions if (pendingJobs == null || pendingJobs.isEmpty()) { return false; } for (JobInfo info : pendingJobs) { if (isJobInfoScheduled(info, request)) { return true; } } return false; }
protected final int schedule(JobInfo jobInfo) { JobScheduler jobScheduler = getJobScheduler(); if (jobScheduler == null) { throw new JobProxyIllegalStateException("JobScheduler is null"); } try { return jobScheduler.schedule(jobInfo); } catch (IllegalArgumentException e) { mCat.e(e); String message = e.getMessage(); if (message != null && message.contains("RECEIVE_BOOT_COMPLETED")) { return ERROR_BOOT_PERMISSION; } else if (message != null && message.contains("No such service ComponentInfo")) { // this will reset the proxy and in the worst case use the AlarmManager throw new JobProxyIllegalStateException(e); } else { throw e; } } catch (NullPointerException e) { /* Attempt to invoke interface method 'int android.app.job.IJobScheduler.schedule(android.app.job.JobInfo)' on a null object reference at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:42) at com.evernote.android.job.v21.JobProxy21.schedule(JobProxy21.java:198) */ mCat.e(e); throw new JobProxyIllegalStateException(e); } }
@Override public void cancel(int jobId) { try { getJobScheduler().cancel(jobId); } catch (Exception e) { // https://gist.github.com/vRallev/5d48a4a8e8d05067834e mCat.e(e); } TransientBundleCompat.cancel(mContext, jobId, null); }
@Override public boolean isPlatformJobScheduled(JobRequest request) { List<JobInfo> pendingJobs; try { pendingJobs = getJobScheduler().getAllPendingJobs(); } catch (Exception e) { // it's possible that this throws an exception, see https://gist.github.com/vRallev/a59947dd3932d2642641 mCat.e(e); return false; } //noinspection ConstantConditions if (pendingJobs == null || pendingJobs.isEmpty()) { return false; } for (JobInfo info : pendingJobs) { if (isJobInfoScheduled(info, request)) { return true; } } return false; }
protected final int schedule(JobInfo jobInfo) { JobScheduler jobScheduler = getJobScheduler(); if (jobScheduler == null) { throw new JobProxyIllegalStateException("JobScheduler is null"); } try { return jobScheduler.schedule(jobInfo); } catch (IllegalArgumentException e) { mCat.e(e); String message = e.getMessage(); if (message != null && message.contains("RECEIVE_BOOT_COMPLETED")) { return ERROR_BOOT_PERMISSION; } else if (message != null && message.contains("No such service ComponentInfo")) { // this will reset the proxy and in the worst case use the AlarmManager throw new JobProxyIllegalStateException(e); } else { throw e; } } catch (NullPointerException e) { /* Attempt to invoke interface method 'int android.app.job.IJobScheduler.schedule(android.app.job.JobInfo)' on a null object reference at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:42) at com.evernote.android.job.v21.JobProxy21.schedule(JobProxy21.java:198) */ mCat.e(e); throw new JobProxyIllegalStateException(e); } }