Datasheet
20
Part I: The Nuts and Bolts of Android
Accelerometer
Android comes packed with accelerometer support. An accelerometer is a
device that measures acceleration. That sounds cool and all, but what can
you do with it? If you want to know whether the phone is moving or being
shaken, or even the direction in which it’s being turned, the accelerometer
can tell you.
You may be thinking, “Okay, but why do I care whether the phone is being
shaken or turned?” Simple! You can use that input as a way to control your
application. You can do simple things like determine whether the phone has
been turned upside down and do something when it happens. Maybe you’re
making a dice game and want to immerse your users in the game play by
having them shake the phone to roll the dice. This is the kind of functionality
that is setting mobile devices apart from typical desktop personal computers.
SD Card
Android gives you the tools you need to access (save and load) files on the
device’s SD Card — a portable storage medium that you can insert into vari-
ous phones and computers. If a device is equipped with an SD Card, you
can use it to store and access files needed by your application. Android 2.2
allows you to install apps on the SD Card, but maybe your users have phones
that don’t get Android 2.2. Just because some users don’t have the option of
installing apps on the SD Card doesn’t mean that you have to bloat your app
with 20MB of resources and hog the phone’s limited built-in memory. You
can download some or all of your application’s resources from your Web
host and save them to the phone’s SD Card. This makes your users happy
and less likely to uninstall your app when space is needed.
Not all devices come with an SD Card installed, although most do. Always
make sure that the user has an SD Card installed and that adequate space is
available before trying to save files to it.
Software Tools
Various Android tools are at your disposal while writing Android applica-
tions. In the following sections, I outline some of the most popular tools that
you will use in your day-to-day Android development process.
05_9780470770184-ch01.indd 2005_9780470770184-ch01.indd 20 11/2/10 8:51 AM11/2/10 8:51 AM