Ejemplo n.º 1
0
        public void ScheduleJob(View v)
        {
            JobInfo.Builder builder = new JobInfo.Builder(102, new ComponentName(this, Java.Lang.Class.FromType(typeof(JobScedulerSample))));
            builder.SetPersisted(true);
            builder.SetPeriodic(5000);
            builder.SetRequiredNetworkType(NetworkType.Unmetered);
            builder.SetRequiresCharging(false);
            builder.SetRequiresDeviceIdle(false);

            try
            {
                int test = Job_s.Schedule(builder.Build());
                if (test == JobScheduler.ResultSuccess)
                {
                    Console.WriteLine("Job is working");
                }
                else
                {
                    Console.WriteLine("Job is not working");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Schedules the task for execution.
        /// </summary>
        public void ScheduleTask(int interval)
        {
            if (!Mvx.IoCProvider.CanResolve <ISettingsManager>())
            {
                return;
            }

            if (!Mvx.IoCProvider.Resolve <ISettingsManager>().IsBackupAutouploadEnabled)
            {
                return;
            }

            var builder = new JobInfo.Builder(SYNC_BACK_JOB_ID,
                                              new ComponentName(
                                                  this, Java.Lang.Class.FromType(typeof(SyncBackupJob))));

            // convert hours into millisecond
            builder.SetPeriodic(60 * 60 * 1000 * interval);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.NotRoaming);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm     = (JobSchedulerType)GetSystemService(JobSchedulerService);
            var status = tm.Schedule(builder.Build());
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Schedules the task for execution.
        /// </summary>
        public void ScheduleTask()
        {
            var builder = new JobInfo.Builder(CLEAR_PAYMENT_JOB_ID,
                                              new ComponentName(
                                                  this, Java.Lang.Class.FromType(typeof(ClearPaymentsJob))));
            // Execute all 60 Minutes
            builder.SetPeriodic(60 * 60 * 1000);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.None);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm = (JobSchedulerType)GetSystemService(JobSchedulerService);
            tm.Schedule(builder.Build());
        }
Ejemplo n.º 4
0
        /* UI onclick listener to schedule a job.What this job is is defined in
         * TestJobService#scheduleJob().
         */

        public void ScheduleJob()
        {
            var builder = new JobInfo.Builder(kJobId++, serviceComponent);


            //builder.SetMinimumLatency(periodInMins * 60 * 1000);
            builder.SetPeriodic((long)periodInMins * 60 * 1000);
            //builder.SetPersisted(true);
            //The service can wait up to an aditional 30 seconds before it must execute


            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);
            notificationService = new LocalNotificationJobService(mainContext);
            notificationService.ScheduleJob(builder.Build());
        }
Ejemplo n.º 5
0
        public void ScheduleTask()
        {
            var builder = new JobInfo.Builder(RECURRING_PAYMENT_JOB_ID,
                                              new ComponentName(
                                                  this, Java.Lang.Class.FromType(typeof(SyncBackupJob))));

            // Execute all 30 Minutes
            builder.SetPeriodic(30 * 60 * 1000);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.None);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm     = (JobSchedulerType)GetSystemService(Context.JobSchedulerService);
            var status = tm.Schedule(builder.Build());
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Schedules the task for execution.
        /// </summary>
        public void ScheduleTask()
        {
            var builder = new JobInfo.Builder(RECURRING_PAYMENT_JOB_ID,
                                              new ComponentName(
                                                  this, Class.FromType(typeof(RecurringPaymentJob))));

            // Execute all 60 Minutes
            builder.SetPeriodic(JOB_INTERVAL);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.None);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm = (JobSchedulerType)GetSystemService(JobSchedulerService);

            tm.Schedule(builder.Build());
        }
Ejemplo n.º 7
0
        // todo p238-239 schedule location job service
        public void StartTracking()
        {
            var javaClass     = Java.Lang.Class.FromType(typeof(LocationJobService));
            var componentName = new ComponentName(Application.Context, javaClass);
            var jobBuilder    = new JobInfo.Builder(1, componentName);

            jobBuilder.SetOverrideDeadline(1000);
            jobBuilder.SetPersisted(true);
            jobBuilder.SetRequiresDeviceIdle(false);
            jobBuilder.SetRequiresBatteryNotLow(true);

            var jobInfo = jobBuilder.Build();

            var jobScheduler = (JobScheduler)Application.Context.GetSystemService(Context.JobSchedulerService);

            jobScheduler.Schedule(jobInfo);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Schedules the task for execution.
        /// </summary>
        public void ScheduleTask(int interval)
        {
            if (!ServiceLocator.Current.GetInstance <ISettingsFacade>().IsBackupAutouploadEnabled)
            {
                return;
            }

            var builder = new JobInfo.Builder(SYNC_BACK_JOB_ID,
                                              new ComponentName(
                                                  this, Class.FromType(typeof(SyncBackupJob))));

            // convert hours into millisecond
            builder.SetPeriodic(JOB_INTERVAL * interval);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.NotRoaming);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm = (JobSchedulerType)GetSystemService(JobSchedulerService);

            tm.Schedule(builder.Build());
        }
        public void ScheduleJob(View v)
        {
            if (!EnsureTestService())
            {
                return;
            }
            var builder = new JobInfo.Builder(kJobId++, serviceComponent);

            var delay = delayEditText.Text;

            if (delay != null && !TextUtils.IsEmpty(delay))
            {
                builder.SetMinimumLatency(long.Parse(delay) * 1000);
            }

            var deadline = deadlineEditText.Text;

            if (deadline != null && !TextUtils.IsEmpty(deadline))
            {
                builder.SetOverrideDeadline(long.Parse(deadline) * 1000);
            }

            bool requiresUnmetered       = wiFiConnectivityRadioButton.Checked;
            bool requiresAnyConnectivity = anyConnectivityRadioButton.Checked;

            if (requiresUnmetered)
            {
                builder.SetRequiredNetworkType(NetworkType.Unmetered);
            }
            else if (requiresAnyConnectivity)
            {
                builder.SetRequiredNetworkType(NetworkType.Any);
            }

            builder.SetRequiresDeviceIdle(requiresIdleCheckbox.Checked);
            builder.SetRequiresCharging(requiresChargingCheckBox.Checked);

            testService.ScheduleJob(builder.Build());
        }
Ejemplo n.º 10
0
        public void ScheduleTask()
        {
            var settingsManager = Mvx.Resolve <ISettingsManager>();

            if (!settingsManager.IsBackupAutouploadEnabled)
            {
                return;
            }

            var builder = new JobInfo.Builder(SYNC_BACK_JOB_ID,
                                              new ComponentName(
                                                  this, Java.Lang.Class.FromType(typeof(SyncBackupJob))));

            // Execute all 30 Minutes
            builder.SetPeriodic(60 * 60 * 1000 * settingsManager.BackupSyncRecurrence);
            builder.SetPersisted(true);
            builder.SetRequiredNetworkType(NetworkType.NotRoaming);
            builder.SetRequiresDeviceIdle(false);
            builder.SetRequiresCharging(false);

            var tm     = (JobSchedulerType)GetSystemService(JobSchedulerService);
            var status = tm.Schedule(builder.Build());
        }
Ejemplo n.º 11
0
		public void ScheduleJob (View v)
		{
			if (!EnsureTestService ()) {
				return;
			}
			var builder = new JobInfo.Builder (kJobId++, serviceComponent);

			var delay = delayEditText.Text;
			if (delay != null && !TextUtils.IsEmpty (delay)) {
				builder.SetMinimumLatency (long.Parse (delay) * 1000);
			}
			var deadline = deadlineEditText.Text;
			if (deadline != null && !TextUtils.IsEmpty (deadline)) {
				builder.SetOverrideDeadline (long.Parse (deadline) * 1000);
			}
			bool requiresUnmetered = wiFiConnectivityRadioButton.Checked;
			bool requiresAnyConnectivity = anyConnectivityRadioButton.Checked;
			if (requiresUnmetered) {
				builder.SetRequiredNetworkCapabilities (NetworkTypeValue.Unmetered);
			} else if (requiresAnyConnectivity) {
				builder.SetRequiredNetworkCapabilities (NetworkTypeValue.Any);
			}
			builder.SetRequiresDeviceIdle (requiresIdleCheckbox.Checked);
			builder.SetRequiresCharging (requiresChargingCheckBox.Checked);

			testService.ScheduleJob (builder.Build ());
		}