示例#1
0
        //###################################################################################

        private void SPINNER_TIME_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            if ((e.Position >= 0) && (e.Position < listSpinnerIntervalValues.Count))
            {
                var interval = listSpinnerIntervalValues[e.Position];

                TBL.UpdateSyncInterval(interval);

                JobSchedulerHelper.CreateSyncJob(this, TBL.GetSyncIntervalSettingDescriptor(this, interval).Timespan);
            }
        }
示例#2
0
        //#############################################################################

        protected override void OnResume()
        {
            base.OnResume();

            //Statischen Speicher erstellen
            InitRoutine(this);

            //Job erstellen
            JobSchedulerHelper.CreateSyncJob(this, TBL.GetSyncIntervalSettingDescriptor(this, TBL.SyncInterval).Timespan);

            //App starten
            StartActivity(new Intent(Application.Context, typeof(Activity_Main)));
        }
示例#3
0
        public static void CreateSyncJob(Context context, int syncInterval)
        {
            var jobBuilder = JobSchedulerHelper.CreateJobBuilderUsingJobId <SyncService>(context, JobSchedulerHelper.JOB_ID);

            if (Build.VERSION.SdkInt < BuildVersionCodes.N)
            {
                jobBuilder.SetPeriodic(syncInterval);
            }
            else
            {
                jobBuilder.SetPeriodic(syncInterval, 300000);
            }

            jobBuilder.SetPersisted(true);
            jobBuilder.SetRequiredNetworkType(NetworkType.Any);
            jobBuilder.SetBackoffCriteria(60000, BackoffPolicy.Exponential);
            var jobInfo = jobBuilder.Build();

            var jobScheduler   = (JobScheduler)context.GetSystemService(Activity.JobSchedulerService);
            var scheduleResult = jobScheduler.Schedule(jobInfo);
        }