CHAPTER 1: The Big Picture
Android has similar concepts, but they are packaged differently and structured to make
phones more crash-resistant:
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 box in a desktop application or the page in a classic web
application. Android is designed to support lots of cheap activities, so
you can allow users to keep tapping to open new activities and
tapping the Back button to back up, just like they do in a web browser.
Services: Activities are 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 to check for
updates to an RSS feed or to play back music even if the controlling
activity is no longer operating. You will also use services for scheduled
tasks (“cron jobs”) and for exposing custom APIs to other applications
on the device, though those are relatively advanced capabilities.
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 applications. Building a content provider lets you do that, while
maintaining complete control over how your data gets accessed.
Intents: Intents are system messages that run around the inside of the
device and notify applications of various events, from hardware state
changes (e.g., an SD card was inserted), to incoming data (e.g., a
Short Message Service [SMS] message arrived), to application events
(e.g., your activity was launched from the device’s main menu). Not
only can you respond to an Intent, but you can create your own to
launch other activities or to let you know when specific situations arise
(e.g., raise such-and-so Intent when the user gets within 100 meters
of this-and-such location).
Stuff at Your Disposal
Storage: You can package data files with your application for things
that do not change, such as icons or help files. You also can carve out
a small bit of space on the device itself, for databases or files
containing user-entered or retrieved data needed by your application.
And, if the user supplies bulk storage, like an SD card, you can read
and write files on there as needed.