Monday, October 5, 2009

Android application Building Block

What Androids Are Made Of



Activities


The building block of the user interface is the activity. You can think of an activity as being the
Android analogue for the window or dialog in a desktop application.
While it is possible for activities to not have a user interface, most likely your “headless”
code will be packaged in the form of content providers or services, like the following described.

Content Providers


Content providers provide a level of abstraction for any data stored on the device that is accessible
by multiple applications. The Android development model encourages you to make your
own data available to other applications, as well as your own—building a content provider lets
you do that, while maintaining complete control over how your data gets accessed.

Intents


Intents are system messages, running around the inside of the device, notifying applications of
various events, from hardware state changes (e.g., an SD card was inserted), to incoming data
(e.g., an SMS message arrived), to application events (e.g., your activity was launched from the
device’s main menu). Not only can you respond to intents, but you can create your own, to
launch other activities, or to let you know when specific situations arise (e.g., raise such-andso
intent when the user gets within 100 meters of this-and-such location).


Services


Activities, content providers, and intent receivers are all short-lived and can be shut down at
any time. Services, on the other hand, are designed to keep running, if needed, independent of
any activity. You might use a service for checking for updates to an RSS feed, or to play back
music even if the controlling activity is no longer operating.

No comments:

Post a Comment