Android services are not the same as Windows services. If you use the Android service, it still works in the main application of your application. They stop when the device goes into sleep mode. In addition, the system can complete maintenance in low memory conditions and possibly in other situations.
From the documentation:
Typically, a running service performs one operation and does not return the result to the caller. For example, it can upload or download a file over the network. When the operation is completed, the service should stop.
and
"if the service has been running and working for a long time, the system will lower its position in the list of background tasks over time and the service will become very susceptible to killing"
Instead of services, AlarmManager may be the best choice. This is a system service that will perform actions when you say, for example, periodically.
source share