Sams Teach Yourself Android Application Development in 24 Hours [NOOK Book]

Overview

In just 24 sessions of one hour or less, learn how to build powerful applications for the world’s first complete, open, and free mobile platform: Android. Using this book’s straightforward, step-by-step approach, you’ll build a fully-featured Android application from the ground up and master the skills you need to design, develop, test, and publish powerful applications. Each lesson builds on what you’ve already learned, giving you a rock-solid...

See more details below
Sams Teach Yourself Android Application Development in 24 Hours

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$17.99
BN.com price
(Save 43%)$31.99 List Price

Overview

In just 24 sessions of one hour or less, learn how to build powerful applications for the world’s first complete, open, and free mobile platform: Android. Using this book’s straightforward, step-by-step approach, you’ll build a fully-featured Android application from the ground up and master the skills you need to design, develop, test, and publish powerful applications. Each lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Some of the highlights of this new edition include:

  • More comprehensive code listings
  • New, improved exercises based upon reader feedback
  • Completely overhauled sample code on a new companion CD
  • New coverage of hot topics like tablet design, services, app widgets, Android Market updates, and more
  • Even more tips and tricks from the trenches to help you design, develop, and test applications for a different device targets, including an all-new chapter on tackling compatibility issues

Learn how to…

  • Develop Android applications quickly and successfully with Java
  • Master the latest Android SDK and development tools
  • Leverage the Eclipse programming environment to develop Android projects
  • Understand the Android application lifecycle
  • Build effective, user-friendly user interfaces
  • Store, retrieve, and manipulate application data
  • Add popular network, social, and location-based features to your applications
  • Take advantage of Android device hardware like the camera
  • Internationalize, test, and publish your applications

Sample code available on CD can also be downloaded at informit.com/title/9780672335693

informit.com/sams

androidbook.blogspot.com

Read More Show Less

Product Details

  • ISBN-13: 9780768696318
  • Publisher: Pearson Education
  • Publication date: 6/24/2010
  • Series: Sams Teach Yourself Series
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 480
  • Sales rank: 822,690
  • File size: 6 MB

Meet the Author

Lauren Darcey is responsible for the technical leadership and direction of a small software company specializing in mobile technologies, including Android, iPhone, Blackberry, Palm Pre, BREW, and J2ME. With more than two decades of experience in professional software production, Lauren is a recognized authority in enterprise architecture and the development of commercial-grade mobile applications. Lauren received a B.S. in Computer Science from the University of California, Santa Cruz.

She spends her copious free time traveling the world with her geeky mobile-minded husband and is an avid nature photographer. Her work has been published in books and newspapers around the world. In South Africa, she dove with 4-meter-long great white sharks and got stuck between a herd of rampaging hippopotami and an irritated bull elephant. She’s been attacked by monkeys in Japan, gotten stuck in a ravine with two hungry lions in Kenya, gotten thirsty in Egypt, narrowly avoided a coup d’état in Thailand, geocached her way through the Swiss Alps, drank her way through the beer halls of Germany, slept in the crumbling castles of Europe, and gotten her tongue stuck to an iceberg in Iceland (while being watched by a herd of suspicious wild reindeer).

Shane Conder has extensive development experience and has focused his attention on mobile and embedded development for the past decade. He has designed and developed many commercial applications for BREW, J2ME, Palm, Windows Mobile, and Android--some of which have been installed on millions of phones worldwide. Shane has written extensively about the mobile industry and evaluated mobile development platforms on his tech blogs and is well known within the blogosphere. Shane received a B.S. in Computer Science from the University of California.

A self-admitted gadget freak, Shane always has the latest phone or laptop. He can often be found fiddling with the latest technologies, such as Amazon Web Services, Android, iPhone, Google App Engine, and other exciting, state-of-the-art technologies that activate the creative part of his brain. He also enjoys traveling the world with his geeky wife, even if she did make him dive with 4-meter-long great white sharks and almost get eaten by a lion in Kenya. He admits that it was his fault they got attacked by monkeys in Japan, that he snickered and whipped out his Android phone to take a picture when Laurie got her tongue stuck to that iceberg in Iceland, and that he still hasn’t learned his lesson about writing his own bio.

Other Publications by the Authors

The authors have also published Android Wireless Application Development, part of the Addison-Wesley Developer’s Library series, as well as numerous online technical articles for http://developer.com, http://informIT.com, and their own Android blog, http://androidbook.blogspot.com.

Read More Show Less

Table of Contents

Introduction 1

    Who Should Read This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    How This Book Is Structured . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    What Is (and Isn’t) in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    What Development Environment Is Used? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    What Conventions Are Used in This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    An Overview of Changes in This Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    About the Short Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    Supplementary Tools Available. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    Part I: Android Fundamentals

HOUR 1: Getting Started with Android 9

    Introducing Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

        Google and the Open Handset Alliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

        Android Makes Its Entrance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

        Cheap and Easy Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    Familiarizing Yourself with Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

        Creating Android Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

        Exploring the Android Project Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

        Editing Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    Running and Debugging Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

        Managing Android Virtual Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

        Creating Debug and Run Configurations in Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . 22

        Launching Android Applications Using the Emulator . . . . . . . . . . . . . . . . . . . . . . . . 24

        Debugging Android Applications Using DDMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

        Launching Android Applications on a Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

HOUR 2: Mastering the Android Development Tools 31

    Using the Android Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    Debugging Applications with DDMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

        Managing Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

        Browsing the Android File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

        Interacting with Emulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

        Taking Screenshots of the Emulator or Handset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

        Viewing Log Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    Working with the Android Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

        Providing Input to the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

        Exploring the Android System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

        Using SD Card Images with the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Using Other Android Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

HOUR 3: Building Android Applications 47

    Designing a Typical Android Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

        Designing Application Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

        Determining Application Activity Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

        Implementing Application Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    Using the Application Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

        Retrieving Application Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

        Accessing Application Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

        Accessing Other Application Functionality Using Contexts. . . . . . . . . . . . . . . . . . 52

    Working with Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

        Launching Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

        Managing Activity State. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

        Shutting Down Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    Working with Intents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

        Passing Information with Intents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

        Using Intents to Launch Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    Working with Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    Working with Fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    Logging Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

HOUR 4: Managing Application Resources 65

    Using Application and System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

        Working with Application Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

        Working with System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    Working with Simple Resource Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

        Working with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

        Working with Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

        Working with Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    Working with Drawable Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

        Working with Images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

        Working with Other Types of Drawables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    Working with Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

        Designing Layouts Using the Layout Resource Editor. . . . . . . . . . . . . . . . . . . . . . . . . . 74

        Designing Layouts Using XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    Working with Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

        Working with XML Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

        Working with Raw Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

        Working with Other Types of Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

HOUR 5: Configuring the Android Manifest File 83

    Exploring the Android Manifest File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

        Using the Manifest Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

        Using the Application Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

        Using the Permissions Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

        Using the Instrumentation Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

        Using the AndroidManifest.xml Tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

    Configuring Basic Application Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

        Naming Android Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

        Versioning an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

        Setting the Minimum Android SDK Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

        Naming an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

        Providing an Icon for an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

        Providing an Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

        Setting Debug Information for an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

        Setting Other Application Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    Defining Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

        Registering Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

        Designating the Launch Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

    Managing Application Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    Managing Other Application Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

HOUR 6: Designing an Application Framework 99

    Designing an Android Trivia Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

        Determining High-Level Game Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

        Determining Activity Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

        Determining Screen-Specific Game Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

    Implementing an Application Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

        Reviewing the Accompanying Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

        Creating a New Android Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

        Adding Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

        Implementing Application Activities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

        Creating Application Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

    Running the Game Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

        Creating a Debug Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

        Launching the Prototype in the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

        Exploring the Prototype Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Part II: Building an Application Framework

HOUR 7: Implementing an Animated Splash Screen 117

    Designing the Splash Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    Implementing the Splash Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

        Updating the Splash Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

    Working with Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

        Adding Animation Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

        Animating Specific Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

        Animating All Views in a Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

        Handling Animation Life Cycle Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

HOUR 8: Implementing the Main Menu Screen 133

    Designing the Main Menu Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

        Determining Main Menu Screen Layout Requirements . . . . . . . . . . . . . . . . . . . . 134

        Designing the Screen Header with RelativeLayout . . . . . . . . . . . . . . . . . . . . . . . . . . 135

        Designing the ListView Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

        Finishing Touches for the Main Menu Layout Design . . . . . . . . . . . . . . . . . . . . . . 135

    Implementing the Main Menu Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

        Updating the Main Menu Screen Layout Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

    Working with the ListView Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

        Filling a ListView Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

        Listening for ListView Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

        Customizing ListView Control Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

    Working with Other Menu Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

        Adding an Options Menu to the Game Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

HOUR 9: Developing the Help and Scores Screens 151

    Designing the Help Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    Implementing the Help Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

        Updating the Help Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    Working with Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

        Adding Raw Resource Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

        Accessing Raw File Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

    Designing the Scores Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

        Determining Scores Screen Layout Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

        Adding the TabHost Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

    Implementing the Scores Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

        Updating the Scores Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    Building a Screen with Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

        Configuring the TabHost Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

        Adding Tabs to the TabHost Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

        Setting the Default Tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    Working with XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

        Retrieving XML Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

        Parsing XML Files with XmlResourceParser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

        Applying Finishing Touches to the Scores Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

HOUR 10: Building Forms to Collect User Input 171

    Designing the Settings Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

    Implementing the Settings Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

        Updating the Settings Screen Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

    Using Common Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

        Working with EditText Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

        Working with Button Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

        Working with Spinner Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    Saving Form Data with SharedPreferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

        Defining SharedPreferences Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

        Saving Settings to SharedPreferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

        Reading Settings from SharedPreferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

HOUR 11: Using Dialogs to Collect User Input 189

    Working with Activity Dialogs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

        Exploring the Different Types of Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

        Tracing the Life Cycle of an Activity Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    Using the DatePickerDialog Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

        Adding a DatePickerDialog to a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

        Initializing a DatePickerDialog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

        Launching DatePickerDialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    Working with Custom Dialogs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

        Adding a Custom Dialog to the Settings Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

HOUR 12: Adding Application Logic 205

    Designing the Game Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

    Implementing the Game Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

        Updating the Game Screen Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

    Working with ViewSwitcher Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

        Initializing Switcher Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

        Implementing Switcher Factory Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

        Updating the TextSwitcher Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

        Updating the ImageSwitcher Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

    Wiring Up Game Logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

        Adding Game State Settings to the SharedPreferences . . . . . . . . . . . . . . . . . . . . . . 216

        Retrieving, Parsing, and Storing Question Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Part III: Enhancing Your Application with Powerful Android Features

HOUR 13: Working with Images and the Camera 227

    Designing the Avatar Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    Adding an Avatar to the Settings Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

        Updating the Settings Screen Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

    Working with ImageButton Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

        Setting the Image of an ImageButton Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

        Handling ImageButton Click Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

    Choosing and Saving the Avatar Graphic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

    Working with Bitmaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

HOUR 14: Adding Support for Location-Based Services 245

    Designing the Favorite Place Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

        Determining Favorite Place Feature Layout Updates . . . . . . . . . . . . . . . . . . . . . . . . 246

        Designing the Favorite Place Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    Implementing the Favorite Place Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

        Adding New Project Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

        Updating the Settings Screen Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

        Implementing the Favorite Place Dialog Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

    Implementing the Favorite Place Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

    Using Location-Based Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

        Enabling Location Testing on the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

        Accessing the Location-Based Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    Using Geocoding Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

        Using Geocoding Services with Android. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

    Working with Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

        Launching a Map Application by Using an Intent . . . . . . . . . . . . . . . . . . . . . . . . . . 263

        Working with Third-Party Services and Applications . . . . . . . . . . . . . . . . . . . . . . . . 265

HOUR 15: Adding Basic Network Support 269

    Designing Network Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

        Working with an Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

        Managing Lengthy Network Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

        Informing the User of Network Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

    Developing Network Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

        Enabling Network Testing on the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

        Testing Network Applications on Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    Accessing Network Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

        Planning Been There, Done That! Network Support. . . . . . . . . . . . . . . . . . . . . . . . . . 274

        Setting Network Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

        Checking Network Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

        Using HTTP Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

    Indicating Network Activity with Progress Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

        Displaying Indeterminate Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

        Displaying Determinate Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

        Displaying Progress Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

    Running Tasks Asynchronously . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

        Using AsyncTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

        Using Threads and Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

    Downloading and Displaying Score Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

        Extending AsyncTask for Score Downloads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

        Starting the Progress Indicator with onPreExecute() . . . . . . . . . . . . . . . . . . . . . . . . 282

        Clearing the Progress Indicator with onPostExecute(). . . . . . . . . . . . . . . . . . . . . . 282

        Handling Cancellation with onCancelled(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

        Handling Processing with doInBackground() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

        Handling Progress Updates with onProgressUpdate() . . . . . . . . . . . . . . . . . . . . . . 285

        Starting the ScoreDownloaderTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

    Downloading and Parsing Question Batches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

        Extending AsyncTask for Question Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

        Starting the Progress Dialog with onPreExecute(). . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

        Dismissing the Progress Dialog with onPostExecute() . . . . . . . . . . . . . . . . . . . . . . 288

        Handling the Background Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

        Starting QuizTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

HOUR 16: Adding Additional Network Features 293

    Determining What Data to Send to the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

    Keeping Player Data in Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

    Uploading Settings Data to a Remote Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

        Working with Android Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

        Implementing UploadTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

        Uploading Player Data with the HTTP GET Method . . . . . . . . . . . . . . . . . . . . . . . . . . 299

        Uploading Avatar Data with the HTTP POST Method . . . . . . . . . . . . . . . . . . . . . . . . 301

    Uploading Score Data to a Remote Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304

    Downloading Friends’ Score Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

HOUR 17: Adding Social Features 309

    Enhancing Applications with Social Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

        Tailoring Social Features to Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

        Supporting Basic Player Relationships. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

    Adding Friend Support to Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

        Enabling Friend Requests on the Settings Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

        Implementing the Friend Request Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

        Enhancing Player Relationships. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

    Integrating with Social Networking Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

        Adding Facebook Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

        Adding Twitter Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

        Working with the OpenSocial Initiative. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

HOUR 18: Creating a Home Screen App Widget 325

    Designing an App Widget. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

        Developing an App Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

        Configuring App Widget Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

        Working with RemoteViews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

        Working with Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

        Designing the App Widget Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

        Implementing an App Widget Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

        Handling App Widget Background Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

        Updating the Android Manifest File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

HOUR 19: Internationalizing Your Application 341

    General Internationalization Principles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

    How Android Localization Works. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

        How the Android Operating System Handles Locale . . . . . . . . . . . . . . . . . . . . . . . . 345

        How Applications Handle Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

        How the Android Market Handles Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

    Android Internationalization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

        Forgoing Application Internationalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

        Limiting Application Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

        Implementing Full Application Internationalization . . . . . . . . . . . . . . . . . . . . . . . . 350

    Using Localization Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

        Determining System Locale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

        Formatting Date and Time Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

        Handling Currencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

HOUR 20: Developing for Different Devices 355

    Configuration Management for Android. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

        Handling Different Screen Orientations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

        Handling Orientation Changes Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . 362

        Supporting Different Screen Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363

        Supporting Different Device Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364

        Developing for Different Android SDKs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

HOUR 21: Diving Deeper into Android 371

    Exploring More Core Android Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

        Declaring and Enforcing Application Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

        Alerting the User with Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

    Designing Advanced User Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

        Using Styles and Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

        Designing Custom View and ViewGroup Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

        Working with Input Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

        Handling User Gestures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

        Converting Text to Speech. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

        Converting Speech to Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

    Working with Multimedia. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

        Playing and Recording Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

        Playing and Recording Video. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

    Working with 2D and 3D Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

        Using the Android Graphics Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

        Using the OpenGL ES Graphics API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    Personalizing Android Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

        Setting the Ringtone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

        Setting the Wallpaper. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

        Creating a Live Wallpaper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

    Managing and Sharing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

        Working with Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

        Storing Structured Data in a SQLite Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

        Sharing Data with Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

        Integrating with Global Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

    Accessing Underlying Device Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

        Reading Raw Sensor Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

        Working with Wi-Fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

        Working with Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

        Managing Power Settings and Battery Life. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

HOUR 22: Testing Android Applications 391

    Testing Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391

        Developing Coding Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

        Performing Regular Versioned Builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

        Using a Defect Tracking System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

        Developing Good Test Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

    Maximizing Test Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

        Managing the Testing Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

        Testing on the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

        Testing on Target Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

        Performing Automated Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

Part V: Publishing Your Application

HOUR 23: Getting Ready to Publish 409

    Understanding the Release Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

    Preparing the Release Candidate Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

        Preparing the Android Manifest File for Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

        Protecting Your Application from Software Pirates . . . . . . . . . . . . . . . . . . . . . . . . . . 412

        Readying Related Services for Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    Testing the Application Release Candidate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    Packaging and Signing an Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

        Digitally Signing Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

        Exporting and Signing the Package File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

    Testing the Signed Application Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

        Installing the Signed Application Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

        Verifying the Signed Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

HOUR 24: Publishing on the Android Market 421

    Selling on the Android Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421

        Signing Up for a Developer Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

        Uploading an Application to the Android Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

        Publishing on the Android Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

        Using Other Developer Account Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

    Exploring Other Android Publishing Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

        Selling Your Application on Your Own Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

        Selling Your Application on Other Markets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430

Part VI: Appendixes

APPENDIX A: Configuring Your Android Development Environment 437

APPENDIX B: Eclipse IDE Tips and Tricks 445

APPENDIX C: Supplementary Materials 453

TOC, 9780672335693, 6/30/2011

 

Read More Show Less

Customer Reviews

Average Rating 2.5
( 9 )
Rating Distribution

5 Star

(1)

4 Star

(2)

3 Star

(1)

2 Star

(3)

1 Star

(2)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com 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 & Noble.com 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 & Noble.com 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 BN.com 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

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com 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 BN.com. 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 all of 9 Customer Reviews
  • Posted October 7, 2011

    more from this reviewer

    Good guide on how to develop an app for Android platform

    This is a well organized book, very easy to follow and give you great perspective on all details of how to build an Android application. It is divided in five major parts plus a series of Appendixes. First part does a quick presentation on Android Fundamentals, Second part covers Building an Application Framework, how you implement Splash Screen and a Menu screen, as well as Help and Scores screen if you are developing a game. Third part covers Enhancing Your Application with Powerful Android Features, that deals with usage of images and cameras, as well as network features and support, and social features. Fourth part is called Adding Polish to Your Android Application and teaches how to internationalize your application, how to develop for different devices and how to test your application. Last but not least, part five teaches you how to get ready to publish your application.
    This book is a valuable tool, explaining in details on how to create the developing environment and which are the best open source tools to use.
    Overall it is a very useful book, that I recommend if you want to start developing applications for Android platform.

    This book was written by Lauren Darcy and Shane Conder and the second edition was Published on August of 2011.

    5 out of 6 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted November 24, 2010

    NOT for beginners!

    The back of the book promised that no Java programming experience was necessary. However, this book jumps right into the main concepts of the Java language with very little explanation. I didn't make it passed the 4th hour.

    4 out of 5 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted January 8, 2013

    Just read teh preview online. Really good material, presented i

    Just read teh preview online. Really good material, presented in easy to understand and follow instructions. Hihgly recommend this.

    Was this review helpful? Yes  No   Report this review
  • Posted August 22, 2012

    Not the status quo for SAMS, and not for beginners at all. Hour

    Not the status quo for SAMS, and not for beginners at all. Hour 8 will
    leave you hopeless.

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

    Posted April 18, 2011

    No text was provided for this review.

  • Anonymous

    Posted October 19, 2012

    No text was provided for this review.

  • Anonymous

    Posted May 17, 2011

    No text was provided for this review.

  • Anonymous

    Posted March 7, 2011

    No text was provided for this review.

  • Anonymous

    Posted January 26, 2011

    No text was provided for this review.

Sort by: Showing all of 9 Customer Reviews

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