Sometimes in my apps I need to do something in the background repeatedly (every X hours).
Up to API 25 i use:
AlarmManager
with setInexactRepeating (to respect battery)WakefulBroadcastReceiver
to have enough times to do all worksIntentService
to do all in background thread
On API 26 all of this are deprecated or limited and are suggested to use JobScheduler
with JobService
instead.
The problem is that JobService
run in main thread.
I think to use AsyncTask
inside JobService
and call JobService.jobFinished
inside onPostExecute
this is the correct way to do this?