i came to know that background services are not a way around in order to perform background task instead Job Scheduler was focused more as an alternative
i was applying the job scheduler functionality in my app and i was so confused that why my job is not running as expected whereas in android emulator it is running smoothly
below is my code which i have applied so far
Java.Lang.Class javaClass = Java.Lang.Class.FromType(typeof(jobsched));
ComponentName component = new ComponentName(this, javaClass)
JobInfo.Builder builder = new JobInfo.Builder(999, component)
.SetMinimumLatency(1000) // Wait at least 1 second
.SetOverrideDeadline(5000) // But no longer than 5 seconds
.SetPersisted(true)
.SetRequiredNetworkType(NetworkType.Any);
JobInfo jobInfo = builder.Build();
JobScheduler jobScheduler = (JobScheduler)GetSystemService(JobSchedulerService);
int result = jobScheduler.Schedule(jobInfo);
if (result == JobScheduler.ResultSuccess)
{
// The job was scheduled.
}
else
{
// Couldn't schedule the job.
}
And Scheduler service
public override bool OnStartJob(JobParameters @params)
{
Task.Run(() =>
{ });
JobFinished(@params, true);
return true;
}
public override bool OnStopJob(JobParameters @params) {
return true;
}
above scheduler seems to work fine when the app is open but when the app is closed by swiping away from recent task it doesn't notify me any more
i am missing something, please help me with this