The Android Developer's Cookbook: Building Applications with the Android SDK

Paperback (Print)
Buy New
Buy New from
Buy Used
Buy Used from
(Save 41%)
Item is in good condition but packaging may have signs of shelf wear/aging or torn packaging.
Condition: Used – Good details
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 95%)
Other sellers (Paperback)
  • All (19) from $1.99   
  • New (4) from $7.11   
  • Used (15) from $1.99   


Want to get started building applications for Android, the world’s hottest, fast-growing mobile platform? Already building Android applications and want to get better at it? This book brings together all the expert guidance–and code–you’ll need!

Completely up-to-date to reflect the newest and most widely used Android SDKs, The Android Developer’s Cookbook is the essential resource for developers building apps for any Android device, from phones to tablets.

Proven, modular recipes take you from the absolute basics to advanced location-based services, security techniques, and performance optimization. You’ll learn how to write apps from scratch, ensure interoperability, choose the best solutions for common problems, and avoid development pitfalls. Coverage includes:

  • Implementing threads, services, receivers, and other background tasks
  • Providing user alerts
  • Organizing user interface layouts and views
  • Managing user-initiated events such as touches and gestures
  • Recording and playing audio and video
  • Using hardware APIs available on Android devices
  • Interacting with other devices via SMS, web browsing, and social networking
  • Storing data efficiently with SQLite and its alternatives
  • Accessing location data via GPS
  • Using location-related services such as the Google Maps API
  • Building faster applications with native code
  • Providing backup and restore with the Android Backup Manager
  • Testing and debugging apps throughout the development cycle

Turn to The Android Developer’s Cookbook for proven, expert answers–and the code you need to implement them. It’s all you need to jumpstart any Android project, and create high-value, feature-rich apps that sell!

Read More Show Less

Product Details

  • ISBN-13: 9780321741233
  • Publisher: Addison-Wesley
  • Publication date: 10/31/2010
  • Series: Developer's Library Series
  • Pages: 339
  • Sales rank: 1,315,713
  • Product dimensions: 6.90 (w) x 8.90 (h) x 0.90 (d)

Meet the Author

James Steele was doing post-doctoral work in physics at MIT when he decided to join a startup in Silicon Valley. Fifteen years later and he continues to innovate, bringing research projects to production in both the consumer and mobile market. He actively presents and participates in various Silicon Valley new technology groups.

Nelson To has more than ten applications of his own in the Android Market. He also has worked on enterprise Android applications for Think Computer, Inc. (PayPhone),AOL (AIM), Stanford University (Education App), and Logitech (Google TV). He also assists in organizing the SiliconValley Android Meetup Community and teaches Android classes both in the Bay Area and China.

Read More Show Less

Table of Contents

1 Overview of Android 1

The Evolution of Android 1

The Dichotomy of Android 2

Devices Running Android 2

HTC Models 6

Motorola Models 6

Samsung Models 6

Tablets 7

Other Devices 7

Hardware Differences on Android Devices 8

Screens 8

User Input Methods 9

Sensors 9

Features of Android 10

Multiprocess and App Widgets 11

Touch, Gestures, and Multitouch 11

Hard and Soft Keyboards 11

Android Development 11

How to Use the Recipes in This Book 12

Designing Applications Well 12

Maintaining Forward Compatibility 13

Robustness 13

Software Development Kit 14

Installing and Upgrading 14

Software Features and API Level 15

Emulator and Android Device Debug 16

Using the Android Debug Bridge 18

Signing and Publishing 18

Android Market 19

End-User License Agreement 19

Improving App Visibility 19

Differentiating an App 20

Charging for an App 20

Managing Reviews and Updates 21

Alternatives to the Android Market 22

2 Application Basics: Activities and Intents 23

Android Application Overview 23

Recipe: Creating a Project and an Activity 24

Directory Structure of Project and Autogenerated

Content 26

Android Package and Manifest File 28

Renaming Parts of an Application 30

Activity Lifecycle 30

Recipe: Utilizing Other Lifecycle Functions 31

Recipe: Forcing Single Task Mode 33

Recipe: Forcing Screen Orientation 34

Recipe: Saving and Restoring Activity Information 34

Multiple Activities 35

Recipe: Using Buttons and TextView 36

Recipe: Launching Another Activity from an Event 37

Recipe: Launching an Activity for a Result Using Speech to Text 41

Recipe: Implementing a List of Choices 43

Recipe: Using Implicit Intents for Creating an Activity 44

Recipe: Passing Primitive Data Types Between Activities 46

3 Threads, Services, Receivers, and Alerts 51

Threads 51

Recipe: Launching a Secondary Thread 51

Recipe: Creating a Runnable Activity 55

Recipe: Setting a Thread’s Priority 57

Recipe: Canceling a Thread 57

Recipe: Sharing a Thread Between Two

Applications 58

Messages Between Threads: Handlers 58

Recipe: Scheduling a Runnable Task from the Main Thread 59

Recipe: Using a Countdown Timer 61

Recipe: Handling a Time-Consuming Initialization 62

Services 64

Recipe: Creating a Self-Contained Service 65

Adding a Broadcast Receiver 69

Recipe: Starting a Service When the Camera Button Is

Pressed 70

App Widgets 72

Recipe: Creating an App Widget 72

Alerts 74

Recipe: Using Toast to Show a Brief Message on the

Screen 74

Recipe: Using an Alert Dialog Box 75

Recipe: Showing Notification in Status Bar 76

4 User Interface Layout 79

Resource Directories and General Attributes 79

Recipe: Specifying Alternate Resources 81

Views and ViewGroups 82

Recipe: Building Layouts in the Eclipse Editor 83

Recipe: Controlling the Width and Height of UI

Elements 86

Recipe: Setting Relative Layout and Layout ID 89

Recipe: Declaring a Layout Programmatically 90

Recipe: Updating a Layout from a Separate

Thread 92

Text Manipulation 94

Recipe: Setting and Changing Text Attributes 95

Recipe: Providing Text Entry 98

Recipe: Creating a Form 100

Other Widgets: From Buttons to Seek Bars 101

Recipe: Using Image Buttons in a Table Layout 102

Recipe: Using Check Boxes and Toggle Buttons 105

Recipe: Using Radio Buttons 108

Recipe: Creating a Drop-Down Menu 110

Recipe: Using a Progress Bar 112

Recipe: Using a SeekBar 114

5 User Interface Events 117

Event Handlers and Event Listeners 117

Recipe: Intercepting a Physical Key Press 117

Recipe: Building Menus 121

Recipe: Defining Menus in XML 126

Recipe: Utilizing the SEARCH Key 127

Recipe: Reacting to Touch Events 128

Recipe: Listening for Fling Gestures 130

Recipe: Using Multitouch 133

Advanced User Interface Libraries 136

Recipe: Using Gestures 136

Recipe: Drawing 3D Images 140

6 Multimedia Techniques 147

Images 148

Recipe: Loading an Image for Manipulation 148

Audio 154

Recipe: Choosing and Playing Back Audio Files 154

Recipe: Recording Audio Files 157

Recipe: Manipulating Raw Audio 158

Recipe: Using Sound Resources Efficiently 163

Recipe: Adding Media and Updating Paths 165

Video 165

7 Hardware Interface 169

Camera 169

Recipe: Customizing the Camera 170

Other Sensors 175

Recipe: Getting a Device’s Rotational Attitude 176

Recipe: Using the Temperature and Light Sensor 179

Telephony 180

Recipe: Utilizing the Telephony Manager 181

Recipe: Listening for Phone States 183

Recipe: Dialing a Phone Number 185

Bluetooth 185

Recipe: Turning on Bluetooth 186

Recipe: Discovering Bluetooth Devices 187

Recipe: Pairing with Bonded Bluetooth Devices 188

Recipe: Opening a Bluetooth Socket 188

Recipe: Using Device Vibration 191

Recipe: Accessing the Wireless Network 191

8 Networking 195

Using SMS 195

Recipe: Autosend an SMS Based on a Received

SMS 197

Using Web Content 204

Recipe: Customizing a Web Browser 204

Recipe: Using an HTTP GET 204

Recipe: Using HTTP POST 209

Social Networking 210

Recipe: Integrating with Twitter 210

9 Data Storage Methods 221

Shared Preferences 221

Recipe: Creating and Retrieving Shared

Preferences 222

Recipe: Using the Preferences Framework 222

Recipe: Changing the UI Based on Stored Data 225

Recipe: Adding a EULA 228

SQLite Database 232

Recipe: Creating a Separate Database Package 232

Recipe: Using a Separate Database Package 236

Recipe: Creating a Personal Diary 239

Content Provider 243

Recipe: Creating a Custom Content Provider 244

File Saving and Loading 249

10 Location-Based Services 251

Location Basics 251

Recipe: Retrieving Last Location 253

Recipe: Updating Location Upon Change 254

Recipe: Listing All Enabled Providers 256

Recipe: Translating a Location to Address (Reverse Geocoding) 258

Recipe: Translating an Address to Location (Geocoding) 261

Using Google Maps 263

Recipe: Adding Google Maps to an Application 265

Recipe: Adding Markers on a Map 267

Recipe: Adding Views to a Map 271

Recipe: Marking the Device’s Current Location on a

Map 274

Recipe: Setting up a Proximity Alert 274

11 Advanced Android Development 277

Android Custom View 277

Recipe: Customizing a Button 277

Android Native Components 283

Recipe: Developing a Native Component 284

Android Security 287

Recipe: Declaring and Enforcing Permissions 288

Android Inter-Process Communication 288

Recipe: Implementing a Remote Procedure Call 289

Android Backup Manager 294

Recipe: Creating a Backup of Runtime Data 294

Recipe: Backing Up Files to the Cloud 296

Recipe: Triggering Backup and Restore 296

Android Animation 298

Recipe: Creating an Animation 299

12 Debugging 303

Eclipse Built-in Debug Tools 303

Recipe: Specifying a Run Configuration 303

Recipe: Using the DDMS 304

Recipe: Debugging Through Breakpoints 306

Android SDK Debug Tools 307

Recipe: Using the Android Debug Bridge 307

Recipe: Using LogCat 307

Recipe: Using the Hierarchy Viewer 309

Recipe: Using TraceView 311

Android System Debug Tools 313

Recipe: Setting up GDB Debugging 315

TOC, 9780321741233, 9/25/2010

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 – 8 of 9 Customer Reviews
  • Anonymous

    Posted March 2, 2011

    Best book on Android Development out there!

    This is a very thorough introduction to developing in android. The examples were saved me hours! Coverage on how to download the SDK, Eclipse, Android .xml files, integrating google maps, etc. etc. The book was very well laid out and was well worth the price. I may get the print copy too to keep on my shelf.

    3 out of 3 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted July 3, 2011

    An excellent recipe book

    This is an excellent resource after you've gotten past the first hump of learning how to program Android. It gives you enough to solve a large percentage of your programming problems, making it a relatively easy task to finish up the rest. This is not a tutorial however. If you're not a developer or haven't figured out the basics for Android development then you should probably look to a tutorial book or read the developers resources on the Android developer site.

    2 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted August 6, 2011

    No text was provided for this review.

  • Anonymous

    Posted January 7, 2011

    No text was provided for this review.

  • Anonymous

    Posted March 9, 2011

    No text was provided for this review.

  • Anonymous

    Posted April 4, 2011

    No text was provided for this review.

  • Anonymous

    Posted March 2, 2011

    No text was provided for this review.

  • Anonymous

    Posted July 31, 2011

    No text was provided for this review.

Sort by: Showing 1 – 8 of 9 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)