I have used FirebaseJobDispatcher
in my project. This is the sample code.
public class MyCustomDispatcher extends JobService {
@Override
public boolean onStartJob(JobParameters job) {
Log.e("MyCustomDispatcher", "onStartJob() called with: " + "job = [" + job.getTag() + "]");
return false;
}
@Override
public boolean onStopJob(JobParameters job) {
Log.e("MyCustomDispatcher", "onStopJob() called with: " + "job = [" + job + "]");
return false;
}
}
And to start my job i have done simple thing in my activity.
FirebaseJobDispatcher firebaseJobDispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = firebaseJobDispatcher.newJobBuilder()
.setService(MyCustomDispatcher.class)
.setTag("service")
.setRecurring(false)
.setTrigger(Trigger.executionWindow(0,10))
.setConstraints(Constraint.ON_ANY_NETWORK)
.build();
firebaseJobDispatcher.mustSchedule(myJob);
It is starting my service and onStartJob()
is being called whenever i schedule my job.
Only problem is when i use firebaseJobDispatcher.cancel("service");
, it is not calling onStopJob()
.
Is it the actual behavior or is there anything that i am missing?