Trying to wrap your head around Activities, Intents, Intent Filters, and the lot when you start with Android development can be daunting.We have tried to distill everything you need to know to start writing Android applications with multiple Activity classes, but we'd be remiss if we didn't mention that there's a lot more here, much of which is discussed throughout the book using practical examples. However, we need to give you a "heads up" about some of these topics now because we talk about these concepts very soon when we cover configuring the Android Manifest file for your application in the next chapter.
One application component is the service.An Android Service is basically an Activity without a user interface. It can run as a background process or act much like a web service does, processing requests from third parties.You can use Intents and Activities to launch services using the startService() and bindService() methods.Any Services exposed by an Android application must be registered in the Android Manifest file.
You can use services for different purposes. Generally, you use a service when no input is required from the user. Here are some circumstances in which you might want to implement or use an Android service:
■ A weather, email, or social network app might implement a service to routinely check for updates. (Note: There are other implementations for polling, but this is a common use of services.)
■ A photo or media app that keeps its data in sync online might implement a service to package and upload new content in the background when the device is idle.
■ A video-editing app might offload heavy processing to a queue on its service in order to avoid affecting overall system performance for non-essential tasks.
■ A news application might implement a service to "pre-load" content by downloading news stories in advance of when the user launches the application, to improve performance.
A good rule of thumb is that if the task requires the use of a worker thread and might affect application responsiveness and performance, consider implementing a service to handle the task outside the main application lifecycle.
We talk a lot more about services in Chapter 21,"Working with Services."
Was this article helpful?
Here's How Anyone Can Start, Build and Run their Own Successful Software Empire Without Knowing the First Thing About Programming, Scripting Or Any 'Coder' Stuff. There is no doubt about it software sells. Software has a high percieved value and it solves problems for people. A claim that can't always be made for PDF books, Video products and the like.