Free Android app covering all aspects of addiction, including prevention and treatment

Bound Services. A way to interact with the Service

Bound Service tutorial icon

Our tutorial app uses a Service to play a sound clip.

We start a Service when the app starts. The Service will run as long as the app is alive.

We need to bind to the Service to start and stop playing a sound clip. We can leave the clip playing in the Service while it is running. It will continue to play even if the activity is paused or destroyed.

Bound Services: a primer

Bound Services primer icon

Quick recap on Services

  • Services are app components that you can use to do work in the background.
  • Services run in your app’s process in the main thread. Don’t block the main thread. Use a separate thread to do any heavy work in your Service.
  • You can also use Services running in another app’s process.
  • Services continue to run until you stop them. The system can also kill them at any time but you can set their priority so that they are unlikely to be killed.

So what happens when we bind to a Service?