public static void StartJobService(this AndroidContext context) { var sch = context.NativeScheduler(); if (!sch.AllPendingJobs.Any(x => x.Id == ANDROID_JOB_ID)) { var job = new Android.App.Job.JobInfo.Builder( ANDROID_JOB_ID, new ComponentName( context.AppContext, Class.FromType(typeof(ShinyJobService)) ) ) .SetPeriodic(Convert.ToInt64(PeriodicJobInterval.TotalMilliseconds)) .SetPersisted(true) .Build(); sch.Schedule(job); } }
public static void StopJobService(this AndroidContext context) => context.NativeScheduler().Cancel(ANDROID_JOB_ID);