Example #1
0
        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);
            }
        }
Example #2
0
 public static void StopJobService(this AndroidContext context) => context.NativeScheduler().Cancel(ANDROID_JOB_ID);