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); }
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"); } }
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); }