I have implemented JobService for my app. The job makes an API call. This has to be done every 4 minutes.
Also the job should start only when the app is being used and should stop when the user exits the app.
I am using setPeriodic to make it run every 4 minutes.
I am planning to do stop/cancel the job in onStop activity lifecycle method. But how do I make sure that the job is stopped/cancelled while the user closes the app?
In onStartJob method, I am returning false once I receive the response for my api call. Will this stop the job? or should I do something else?