I am trying to implement my first JobService. I understand that a call to onStartJob
is practically guaranteed (yes there are some edges if I specify some outrageous requirements without an expiration time). But how about onStopJob
? Is it guaranteed to be called?
To be specific I have a job that will be performed in the background. But I have a way to know when the job is done (e.g. sharedPrefs). I was hoping to rely on when onStopJob is called to send a Notification to the user that the job is done.
Note: onStopJob is a convenient place for sending the notification since I am already checking whether the job is done so to know if I should retry.
p.s. Something to consider that might help (I am considering it too): If my onStartJob
returns true, how does the system know when my job stops running unless it calls onStopJob
?