On device with Android Oreo 8.0 (API level 26) JobService.onTaskRemoved()
isn't called
- How to listen for such an event?
Code used which stopped working:
class TaskRemovalWatcherService: JobIntentService() {
...
override fun onTaskRemoved(rootIntent: Intent?) {
//not called on Android Oreo
super.onTaskRemoved(rootIntent);
onAppRemovedFromRecentApps()
}
}
When App-Task is removed from recent apps I need to
- Stop a process
- Finish 2nd AppTask
if AppTasks.size = 2 and 1 task is removed from recent apps, then process is NOT killed, because 2nd AppTask still in memory.
Update:
- when use
JobIntentService.enqueueWork
then right afterJobIntentService.onHandleWork()
JobIntentService.onDestroy()
is called - when use
JobService.schedule()
throwsIllegalArgumentException
when schadule job without constraints.
P.S. The idea of checking each X seconds isTaskWasRemoved seems not a good one.