Exemplo n.º 1
0
        public override bool OnStartJob(JobParameters jobParams)
        {
            Task.Run(() =>
            {
                // Work is happening asynchronously
                LogtoFileHelper.Write("Started background Task");
                // Have to tell the JobScheduler the work is done.
                JobFinished(jobParams, false);
            });

            // Return true because of the asynchronous work
            return(true);
        }
Exemplo n.º 2
0
        public override void OnReceive(Context context, Intent intent)
        {
            var jobInfo = context.CreateJobBuilderUsingJobId <DownloadJob>(45)
                          .SetPeriodic(1000 * 60 * 15)//15 minutes is the smallest anways
                          .SetRequiredNetworkType(NetworkType.Any)
                          .SetPersisted(true)
                          .Build();

            if (context.Schedule(jobInfo))
            {
                LogtoFileHelper.Write("Successfully Scheduled Job");
            }
            else
            {
                LogtoFileHelper.Write("Failed Scheduled Job");
            }
        }
Exemplo n.º 3
0
 public override bool OnStopJob(JobParameters jobParams)
 {
     LogtoFileHelper.Write("OnStopJob Task");
     // we don't want to reschedule the job if it is stopped or cancelled.
     return(false);
 }