I have an android application that in onCreate
method of Main ACtivity starts a Background Service.
This is a lightweight Service and I want to keep it running all the time. So , I return START_STCKY
in onStartCommand()
method of Service.
When App is launched and the service starts running,in case,if Only Running Service is killed from the Settings ,and then if App is relaunched ,the onCreate
method of app is not called and Service is not restarted.
If I start my Service in onResume() method of Activity , it does not seem to be a good practice to keep on checking if my Service is running or not.
How to handle this situation? I want that when the service is killed and app is relaunched , even though the app was running in background, the service should be restarted.