What happens to a recurring job that is not finished due to a crash or Android process cleaning? In my opinion, it is not possible to reschedule it. It will never be executed again.
Example
public class MyJobService extends JobService {
@Override
public boolean onStartJob(JobParameters job) {
doSomeWork(job);
return true; // true = there is still work going on!
}
private void doSomeWork(final JobParameters job) {
new Thread() {
public void run() {
// do some work, maybe load data from internet
// loading...
// loading...
// app crashes or its process is killed by Android
// this piece of code is never reached!
jobFinished(job, false);
}
}.start();
}
}
As you can see in the code, the job can never be terminated by the crash. It will not be rescheduled afterwards.
If you want to reschedule it with FirebaseJobDispatcher.mustSchedule()
, this appears in logcat:
E/FJD. ExternalReceiver: Received execution request for already running job
W/FJD. JobService: Job with tag = ... was already running
even if you run FirebaseJobDispatcher.cancel()
before.
Any suggestions?