A service is a component that can be run in the Android background, even if your app is turned off, and it's still running. So only if you need a background program that is not relevant to the current program, just create it.
And if you just want your app to work outside the main thread, and the operation is limited to the current program, just create another thread inside.
For example, if you just want to put a piece of music in your activity while it is running, you should create another thread in the Oncreat () method, start the thread in OnStart (), end the thread in OnStop (), and consider using Asynctask Orhandlerthread, instead of using the traditional threading class thread. (PS: Here you can refer to the processes and threading documentation, if you do not understand, I can translate to you see)
Keep in mind that if you do create a service, you should also create another thread in the service, otherwise, by default, the service takes up the main thread, which can cause threads to clog or memory to be overused. This is because unless you create another thread, a service will only run on his managed thread, which means that if you use the service to do any CPU intensive or blocking operations,
Your app will appear stuck or not responding to errors (ANR).
"Android API Guides (iv)" Using a service or using threads?