I have a android service wich needs to be running even if activity is closed!
If screen get OFF the service does not need to do anything.
If screen get ON the service start their work!
So my question is, its better remove all handler callbacks (keeping service) or stop the entire service and when screen get ON start service again?
Thanks!
in principal, it's always would be better to stop all running services if they are not needed.
from battery consumption aspects - running Service
itself don't have any significant affect on the battery consumption, but as long as your Service still alive - your entire process is still alive - what means that your app still consume RAM amount, and considered "running". let's say that the fact itself that your app is running don't have also such impact on the battery life.
but (and there's a big but)
what's do matters, and could have huge impact on battery life is what you are doing within your Service.
from your question I can assume that you are executing some code in some time interval, and thus - you are consuming at each execution CPU time, and maybe even worse - performing network request / performing IO file operations and so on. performing such operations frequently could drain very fast the battery , and you should avoid them as much as possible.
so, if you performing one or more from the operations I mentioned - it's defiantly would be better to not perform them when the screen is off, and not only ignore their callbacks...
I advice you also to watch the entire video - http://www.youtube.com/watch?v=OUemfrKe65c
it's would make you understand the whole picture...