Possible Duplicate
I have created a JobDispatcher service to keep getting user location in background and post user location to server. For that i have created a Job as
you need to cancel job in itself by unregistering location listener and calling jobFinished()
inside LocationJobService.
As dispatcher.cancelAll()
works only to cancel scheduled jobs which are yet to be run.
You may use tools like Eventbus
to inform service when to stop.
Refer https://medium.com/google-developers/scheduling-jobs-like-a-pro-with-jobscheduler-286ef8510129 for more info.