Beginning Android Tablet Application Development

Beginning Android Tablet Application Development

by Wei-Meng Lee


$29.23 $34.99 Save 16% Current price is $29.23, Original price is $34.99. You Save 16%.

Temporarily Out of Stock Online

Eligible for FREE SHIPPING


Beginning Android Tablet Application Development by Wei-Meng Lee

A full-color, fast-paced introduction to developing tablet applications using Android

The new release of Android 3 brings the full power of Android to tablet computing and this hands-on guide offers an introduction to developing tablet applications using this new Android release. Veteran author Wei-Meng Lee explains how Android 3 is specifically optimized for tablet computing and he details Android's tablet-specific functions. Beginning with the basics, this book moves at a steady pace to provide everything you need to know to begin successfully developing your own Android tablet applications.

  • Serves as a full-color, hands-on introduction to developing tablet applications with the new Android 3
  • Offers a helpful overview of Android 3 programming for tablets
  • Details the components of Android tablet applications
  • Highlights ways to build the Android user interface for tablets, create location-based services, publish Android applications, use Eclipse for Android development, and employ the Android emulator

Beginning Android Tablet Application Development is an ideal starting point for getting started with using Android 3 to develop tablet applications.

Product Details

ISBN-13: 9781118106730
Publisher: Wiley
Publication date: 08/09/2011
Pages: 288
Product dimensions: 7.30(w) x 9.10(h) x 0.60(d)

About the Author

Wei-Meng Lee is a technologist and founder of Developer Learning Solutions (, a technology company that specializes in hands-on training in the latest Microsoft and Apple technologies. He writes extensively for online publications and magazines and is the author of Beginning iOS 4 Application Development, Beginning Android Application Development, and many other technology books and articles.

Read an Excerpt

Beginning Android Tablet Application Development

By Wei-Meng Lee

John Wiley & Sons

Copyright © 2011 John Wiley & Sons, Ltd
All right reserved.

ISBN: 978-1-1181-0673-0

Chapter One

Getting Started with Android Programming for Tablets


* What is Android?

* Android versions and its feature set

* The Android architecture

* The various Android devices on the market

* The Android Market application store

* How to obtain the tools and SDK for developing Android applications * How to develop your first Android application

Welcome to the world of Android! When I was writing my first book on Android (which was just a couple of months ago), I stated that Android was ranked second in the U.S. smartphone market, second to Research In Motion's (RIM) BlackBerry, and overtaking Apple's iPhone. Shortly after the book went to press, comScore (a global leader in measuring the digital world and the preferred source of digital marketing intelligence) reported that Android has overtaken BlackBerry as the most popular smartphone platform in the U.S.

Indeed. With Google's recent introduction of Android 3.0, code-named Honeycomb, it's a perfect time to start learning about Android programming. In my first book, Beginning Android Application Development (Wrox, 2011), I focused on getting readers started with the building blocks of Android programming, with particular emphasis on developing applications for Android smartphone applications. With the release of Android 3.0, Google's focus in this new SDK is the introduction of several new features designed for wide-screen devices, specifically tablets. This focus was the impetus behind the book you are currently holding. Therefore, it also focuses on the various features that are specific to wide-screen devices, and contains enough information that can get you jumpstarted with Android tablet development quickly. Readers who want more comprehensive coverage on Android development in general should start with my Beginning Android Application Development book first, and then read this book for information on designing for tablets.

In this chapter you will learn what Android is, and what makes it so compelling to both developers and device manufacturers alike. You will also get started with developing your first Android application, and learn how to obtain all the necessary tools and set them up so that you can test your application on an Android 3.0 tablet emulator. By the end of this chapter, you will be equipped with the basic knowledge you need to explore more sophisticated techniques and tricks for developing your next killer Android tablet application.


Android is a mobile operating system that is based on a modified version of Linux. It was originally developed by a startup of the same name, Android, Inc. In 2005, as part of its strategy to enter the mobile space, Google purchased Android and took over its development work (as well as its development team).

Google wanted Android to be open and free; hence, most of the Android code was released under the open-source Apache License, which means that anyone who wants to use Android can do so by downloading the full Android source code. Moreover, vendors (typically hardware manufacturers) can add their own proprietary extensions to Android and customize Android to differentiate their products from others. This simple development model makes Android very attractive and has thus piqued the interest of many vendors. This has been especially true for companies affected by the phenomenon of Apple's iPhone, a hugely successful product that revolutionized the smartphone industry. Such companies include Motorola and Sony Ericsson, which for many years have been developing their own mobile operating systems. When the iPhone was launched, many of these manufacturers had to scramble to find new ways to revitalize their products. These manufacturers see Android as a solution — they will continue to design their own hardware and use Android as the operating system that powers it.

The main advantage of adopting Android is that it offers a unified approach to application development. Developers need only develop for Android, and their applications should be able to run on numerous different devices, as long as the devices are powered using Android. In the world of smartphones, applications are the most important part of the success chain. Device manufacturers therefore see Android as their best hope to challenge the onslaught of the iPhone, which already commands a large base of applications.

Android Versions

Android has gone through quite a number of updates since its first release. Table 1-1 shows the various versions of Android and their codenames.

In February 2011, Google released Android 3.0, a tablet-only release supporting wide-screen devices. The key changes in Android 3.0 are as follows:

* New user interface optimized for tablets

* 3D desktop with new widgets

* Refined multi-tasking

* New web browser features, such as tabbed browsing, form auto-fill, bookmark syncing, and private browsing

* Support for multicore processors

Applications written for versions of Android prior to 3.0 are compatible with Android 3.0 devices, and they run without modifications. Android 3.0 tablet applications that make use of the newer features available in 3.0, on the other hand, will not be able to run on older devices. If you want to ensure that an Android tablet application is able to run on all versions of devices, you must programmatically ensure that you only make use of features that are supported in specific versions of Android. To do so, you can make use of the android.os.Build.VERSION.SDK constant. The following code snippet shows how you can determine the version of the device during runtime:

int version = Integer.parseInt(android.os.Build.VERSION.SDK); switch (version) { case 8: //-use features specific to Android 2.2- break; case 9: //-use features specific to Android 2.3.1- break; case 10: //-use features specific to Android 2.3.3- break; case 11: //-use features specific to Android 3.0- break; }

Android Devices in the Market

Android devices come in all shapes and sizes. As of late May 2010, the Android OS powers all of the following types of devices:

* Smartphones

* Tablets

* E-reader devices

* Netbooks

* MP4 players

* Internet TVs

Increasingly, manufacturers are rushing out to release Android tablets. Tablet sizes typically start at seven inches, measured diagonally. Figure 1-1 shows the Samsung Galaxy Tab (top), a seven-inch tablet, and the Dell Streak (bottom), a five-inch tablet.

While the Samsung Galaxy Tab and the Dell Streak run the older Android 2.x, the newer tablets run the latest Android 3.0 Honeycomb. Figure 1-2 shows the Motorola Xoom.

Besides the Motorola Xoom, the LG Optimus Pad, shown in Figure 1-3, is another Android 3.0 device, running the latest Android Honeycomb OS.

The Android Market

As mentioned earlier, one of the main factors determining the success of a smartphone platform is the applications that support it. It is clear from the success of the iPhone that applications play a very vital role in determining whether a new platform swims or sinks. In addition, making these applications accessible to the general user is extremely important.

As such, in August 2008, Google announced the Android Market, an online application store for Android devices, and made it available to users in October 2008. Using the Market application that is preinstalled on their Android device, users can simply download third-party applications directly onto their devices. Both paid and free applications are supported on the Android Market, though paid applications are available only to users in certain countries due to legal issues.

Similarly, in some countries, users can buy paid applications from the Android Market, but developers cannot sell in that country. As an example, at the time of writing, users in India can buy apps from the Android Market, but developers in India cannot sell apps on the Android Market. The reverse may also be true; for example, users in South Korea cannot buy apps on the Android Market, but developers in South Korea can sell apps on it.


Naturally, you are anxious to get your hands dirty and start writing some applications! Before you write your first tablet application, however, you need to download the required tools and SDKs.

For Android development, you can use a Mac, a Windows PC, or a Linux machine. All the tools needed are free and can be downloaded from the Web. All the examples provided in this book will work fine with the Android emulator.

NOTE This book uses a Windows 7 computer to demonstrate all the code samples. If you are using a Mac or a Linux computer, the screenshots should look similar; minor differences may be present, but you should be able to follow along without problems.

So, let the fun begin!

Java JDK

The Android SDK makes use of the Java SE Development Kit (JDK). Hence, if your computer does not have the JDK installed, you should start off by downloading the JDK from technetwork/java/javase/downloads/index.html and installing it prior to moving to the next section.


The first step toward developing any applications is obtaining the integrated development environment (IDE). In the case of Android, the recommended IDE is Eclipse, a multi-language software development environment featuring an extensible plug-in system. It can be used to develop various types of applications, using languages such as Java, Ada, C, C++, COBOL, Python, and others.

For Android development, you should download the Eclipse IDE for Java EE Developers (www Six editions are available: Windows (32 and 64-bit), Mac OS X (Cocoa 32 and 64), and Linux (32 and 64-bit). Simply select the relevant one for your operating system. All the examples in this book were tested using the 32-bit version of Eclipse for Windows.

Once the Eclipse IDE is downloaded, unzip its contents (the eclipse folder) into a folder, say C:\Android\.

Downloading the Android SDK

The next important piece of software you need to download is, of course, the Android SDK. The Android SDK contains a debugger, libraries, an emulator, documentation, sample code, and tutorials.

You can download the Android SDK from (see Figure 1-4).

For Windows users, there are two ways in which you can download the Android SDK — either you download the entire Android SDK package — android-sdk_ or you can download the SDK installer — installer_ For beginning Android developers, I strongly encourage you to download the latter, as it makes it very easy for you to get started.

Once the package is downloaded, double-click on it to start the installation process. It will first detect whether the JDK is installed and will only continue if it finds one installed on your computer. Next, you will be asked to choose a destination folder for installing the SDK (see Figure 1-5). Remember the path to this folder because you need to use it later.

Click Next to continue.

You will next be asked to choose a Start Menu folder to install the Android SDK shortcut. Use the default Android SDK Tools folder and click Install. When the installation is complete, click Finish (see Figure 1-6). Doing so will start the SDK Manager, which downloads all the necessary packages for you to test your Android applications.

Installing the Packages

When the SDK Manager is started, it first checks for the packages that are available for installation. The packages contain the documentation and SDK specific to each version of the Android OS. They also contain sample code and tools for the various platforms.

Figure 1-7 shows the various SDK packages that you can install on your computer. Double-click on each package name to select or deselect a package. If you are not sure which packages to install, you might want to select the Accept All radio button to download and install all the packages.

Click Install to proceed with the downloading and installation of the various selected packages.

Each version of the Android OS is identified by an API level number. For example, Android 3.0 is level 11 (API 11), while Android 2.3.3 is level 10 (API 10), and so on. For each level, two platforms are available. For example, level 11 offers the following:

* SDK Platform Android 3.0 * Google APIs by Google Inc., Android API 11, revision 1

The key difference between the two is that the Google APIs platform contains the Google Maps library. Therefore, if the application you are writing requires Google Maps, you need to create an AVD using the Google APIs platform.

Downloading and installing the packages takes some time, so you have to be patient. When all the packages are installed, click Close. You should now see a listing of all the packages installed (see Figure 1-8).

Creating Android Virtual Devices (AVDs)

Once the packages are downloaded and installed, the next step is to create an Android Virtual Device (AVD) to be used for testing your Android applications. An AVD is an emulator instance that enables you to model an actual device. Each AVD consists of a hardware profile, a mapping to a system image, as well as emulated storage, such as a secure digital (SD) card.

You can create as many AVDs as you want in order to test your applications with several different configurations. This testing is important to confirm that your application behaves as expected when it is run on different devices with varying capabilities.

NOTE Appendix B discusses some of the capabilities of the Android emulator.

To create an AVD, select the Virtual Devices item in the left pane of the Android SDK and AVD Manager window (see Figure 1-9).

Then click the New ... button located in the right pane of the window. In the Create new Android Virtual Device (AVD) window, enter the items as shown in Figure 1-10. Click the Create AVD button when you are done.

In this case, you have created an AVD (put simply, an Android emulator) that emulates an Android device running version 3.0 of the OS. In addition to what you have created, you also have the option to emulate the device with an SD card and different screen densities and resolutions.

NOTE Appendix B explains how to emulate the different types of Android devices.

It is preferable to create a few AVDs with different API levels so that your application can be tested on different devices. To emulate the Motorola Xoom, you should choose the "Google APIs (Google Inc.) - API Level 11" target.

To see what the Android emulator looks like, select the AVD you have just created and click the Start ... button. Figure 1-11 shows the Android 3.0 emulator.

Click and move the lock icon to touch a circle that appears when you move the mouse. This unlocks the emulator. Figure 1-12 shows the main window of the Android 3.0 screen.

Clicking the Apps icon on the top-right corner of the screen reveals a list of installed applications on the device (see Figure 1-13).

Android Development Tools (ADT)

With the Android SDK and AVD set up, it is now time to configure Eclipse to recognize the Android project template. The Android Development Tools (ADT) plug-in for Eclipse is an extension to the Eclipse IDE that supports the creation and debugging of Android applications. Using the ADT, you will be able to do the following in Eclipse:

* Create new Android application projects * Access the tools for accessing your Android emulators and devices * Compile and debug Android applications * Export Android applications into Android Packages (APKs) * Create digital certificates for code-signing your APK

To install the ADT, first launch Eclipse by double-clicking the eclipse.exe file located in the eclipse folder.


Excerpted from Beginning Android Tablet Application Development by Wei-Meng Lee Copyright © 2011 by John Wiley & Sons, Ltd. Excerpted by permission of John Wiley & Sons. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Table of Contents















Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews