To start with, I am aware of all questions and answers in this stackoverflow question, in the official documentation and in this github sample project
Unfortunately, from my testing I couldn't verify the whole "tasks continue to run after force-stop" observation noted in the links i provided. Maybe this has now been fixed?
Anyway, what I am trying to accomplish is to reschedule my tasks only after the user opens their application for the first time after a force stop.
Let's say that I have a task that should run once a month. What I want to do is schedule it only once the first time the application starts (via the Once library https://github.com/jonfinerty/Once). This task will run just fine until the user force stops the app. At that point I obviously don't care about the task not running as the user has force-stopped it, but I do want the job to be rescheduled as soon as the user opens up the application again.
It seems like there's no obvious place in code to do that. If I do it in the application class for example, the task will be rescheduled, but it will also be rescheduled every time the app starts, which is not something I want. For example if I schedule a task once a month ever time the application starts then this task will effectively never run, as it will be scheduled every day (when the user opens the app) one month into the future, again and again.
Any thoughts on how I can perform this? This should be a very common scenario, unless there's something i'm missing.
Cheers