Skip to content

Instantly share code, notes, and snippets.

@mahdi-malv
Created December 28, 2019 13:36
Show Gist options
  • Save mahdi-malv/d0f804629d8d6ec8805bca03a9e63503 to your computer and use it in GitHub Desktop.
Save mahdi-malv/d0f804629d8d6ec8805bca03a9e63503 to your computer and use it in GitHub Desktop.
cancelAndroidJob
public static void cancelJob(Context c, int jobId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
JobScheduler jobScheduler =
(JobScheduler) c.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancel(jobId);
}
}
// Call it like this
cancelJob(context, jobId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment