Hardware Tools

Google gives developers (even independent ones) the tools that are necessary to create top-notch, full-featured mobile apps. Google makes it simple to tap into, and make use of, all available hardware on a device.

To create a spectacular Android app, you should take advantage of all that the hardware has to offer. Don’t get us wrong — if you have an idea for an app that needs no hardware assistance, that’s okay, too.

Android devices come supplied with several hardware features that you can use to build apps. Table 1-1 describes the hardware features available on most Android devices.

Table 1-1 Android Device Hardware

Android Hardware Feature

What It Does

Accelerometer

Indicates whether the phone is moving

Bluetooth radio

Indicates whether a headset is connected

Built-in compass

Indicates in which direction the user is heading

Camera

Records video

GPS radio

Indicates the user’s location

Proximity sensor

Indicates whether the device is facing up or down

Most Android devices are released with the hardware discussed in the following four sections, but not all devices are created equal. Android is free for hardware manufacturers to distribute, so it’s used in a wide range of devices, including some made by small manufacturers overseas (and it isn’t uncommon for some of these devices to be missing a feature or two).

Android devices come in all shapes and sizes: phones, tablets, and e-book readers. You will find many other implementations of Android in the future, such as Google TV (an Android-powered home appliance) as well as cars with built-in, Android-powered, touchscreen computers. The engineers behind Android provide tools that let you easily deploy apps on multiple screen sizes and resolutions. Don’t worry — the Android team has done all the hard work for you. Chapter 4 covers the basics of screen sizes and densities.

Touchscreen

The Android touchscreen opens a ton of possibilities to enhance users’ interaction with your apps. Users can swipe, flip, drag, or pinch to zoom, for example, by moving a finger on the touchscreen. You can even supply custom gestures in your app, which opens even more possibilities.

Android also supports multitouch capability, which lets a user touch the entire screen with more than one finger at a time.

Hardware buttons are old news. You can place buttons of any shape anywhere on the screen to create the user interface best suited for your app.

GPS

Combining the Android operating system with the GPS radio on a device lets the developer access, and track, a user’s location at any time. The Foursquare social networking app is a good example — it uses the GPS feature to determine the user’s location and then accesses the web to determine the closest venues to the user.

Another helpful example is the Maps application’s ability to pinpoint a user’s location on a map and provide directions to that person’s destination. Combining Android with GPS hardware gives you access to the user’s exact GPS location. Many apps use this combination to show users where the nearest gas station, coffeehouse, or even restroom is located.

Accelerometer

An accelerometer is a device that measures acceleration, and Android comes packed with accelerometer support. The accelerometer tells you whether a user’s device is being moved or shaken, and even in which direction it’s being turned. You can then use this information as a way to control your application.

You can use the accelerometer to perform simple tasks, such as determine when the device has been turned upside down and then complete an action. For example, you can immerse users in game play by having them shake their device to roll the dice. This level of usefulness 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 compatible phones, tablets, and computers. Starting with Android version 2.2 (Froyo), if a device is equipped with an SD card, you can use the card to store and access files that are needed by your application. To avoid bloating your app with extra required resources and hogging limited built-in memory, you can download some or all of your application’s resources from your web host and save them to the device’s SD card (which makes users less likely to uninstall your app when they need to clear space on their devices).

tip.eps Not every device has an SD card preinstalled, though most do. Always ensure that a device has an SD card installed and that adequate space is available before trying to save files to it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset