Services
Services are top-level application components such as activities. Their purpose is to manage long-running background tasks such as playing audio or triggering reminders or other scheduled events. Services do not require a UI, but in other respects they are similar to activities and have a similar life cycle with associated callback methods that we can use to intercept key events.
Although all services start out the same, they basically fall into two categories, bound and unbound. A service that is bound to an activity will continue to run until instructed otherwise or the binding activity is stopped. An unbound service, on the other hand, will continue to run regardless of whether the calling activity is active or not. In both these cases, the service will often be responsible for switching itself off once it has completed its allotted task.
The following example demonstrates how to create a service that will set a reminder. The service will then either post a notification after a...