Skip to content
tezvyn:

Started vs. Bound Services: Differences and Use Cases

Source: developer.android.comEasyHow cards are made

Started vs. Bound Services: Differences and Use Cases

Tests Android component lifecycle and IPC knowledge. A good answer defines lifecycle control (start vs. bind), communication (one-way vs. two-way IBinder), and gives clear use cases. A red flag is assuming services run on a background thread by default.

What's really being asked

This question tests your fundamental knowledge of Android's component model, specifically lifecycle management and inter-component communication. For a senior role, the interviewer is listening for more than just definitions. They want to see if you understand the architectural implications: how each service type affects resource management, app responsiveness (main thread blocking), and when to use modern alternatives like WorkManager. It's a test of both core knowledge and awareness of current best practices.

The full answer

A strong answer addresses four key points. First, explain the lifecycle difference: a Started service runs independently until it calls stopSelf() or is explicitly stopped, while a Bound service's lifecycle is tied to the component(s) bound to it. Second, describe the communication model: Started services are "fire and forget," communicated with via Intents, while Bound services offer a client-server interface via an IBinder for direct method calls. Third, provide clear use cases: a Started service for a one-off operation like syncing data, and a Bound service for a music player controlled by a UI. Finally, for a senior-level answer, contextualize this by mentioning that WorkManager is now the recommended solution for most deferrable background tasks, replacing many historical uses of StartedService.

The mistakes people make

The most common mistake is stating that services run on a background thread by default. They do not; they run on the application's main thread. Failing to handle threading within a service is a major red flag that indicates a lack of practical experience. Another wrong answer is being unable to explain how a Bound service communicates, i.e., failing to mention the IBinder interface. Finally, presenting StartedService as the go-to for all background tasks without acknowledging WorkManager shows outdated knowledge.

What usually comes next

Expect questions like: "How would you handle threading inside a Started Service?" (Answer: IntentService (deprecated), or manually creating a thread/using coroutines). "What is AIDL and when would you use it with a Bound Service?" (Answer: For inter-process communication when the service and client are in different applications). "How does a Foreground Service relate to Started and Bound Services?" (Answer: It's a type of Started Service that the user is actively aware of, requiring a persistent notification).

A concrete example

For a Started Service, imagine a photo editing app. When the user hits "Export," you start a service with an Intent containing the image URI and export settings. The service runs in the background, processes the image, saves it to disk, and calls stopSelf() when done. It might show a progress notification, but the UI can be closed. For a Bound Service, consider a podcast app. The Activity containing the player UI binds to a PlayerService. The UI can then call methods directly on the service like service.play(), service.pause(), or service.seekTo(30000). The service can also send updates back to the UI. When the user leaves the player UI, the Activity unbinds.

Interview question

When using a Started Service for a long-running task like a file download, what is the most critical step to ensure the app's UI remains responsive?

  • a.Bind a component to the service to keep it alive during the operation.
  • b.Move the download logic to a background thread created within the service.Correct
  • c.Ensure the service calls stopSelf() correctly once the download is complete.
  • d.Start it as a foreground service to give it higher system priority.
Why?

Services run on the application's main thread by default. To prevent the UI from freezing, any long-running operation must be explicitly moved to a separate worker thread. While starting it as a foreground service (D) is common for long tasks, it doesn't solve the main thread blocking issue.

Just read this? Test yourself on what you have been reading.

Read the original → developer.android.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.

See open roles