Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Created February 10, 2020 14:15
Show Gist options
  • Save MrCrambo/e81e905d1e79ff822b146be8ba9a1a5f to your computer and use it in GitHub Desktop.
Save MrCrambo/e81e905d1e79ff822b146be8ba9a1a5f to your computer and use it in GitHub Desktop.
JobScheduler jobShedulerService = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobShedulerService.schedule(new JobInfo.Builder(ID, new ComponentName(context, NavigineJobService.class.getName()))
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) // any network type
.setPeriodic(15 * 60 * 1000) // every 15 minutes
.setRequiresCharging(false) // if device should be charging
.build());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment