I want to handle an Androids application work in the background. I've read that I have to use services for this. In this application, I need to know when the screen gets locked and when it gets unlocked again. Every time this happens, I have to do some actions.
For activities, I've seen we have onPause and onRestart for this, but I need to know when the screen is turned off and when it is turned on in a service. How can this information be retrieved from inside a service.