Introduction To Android Application Development: Android .

Transcription

Praise for Introduction to Android Application Development,Fourth Edition“Introduction to Android Application Development, Fourth Edition, is a phenomenal read andallows those interested in Android development to be brought up to speed and developing apps with minimal fuss. Everything from an introduction to the Android ecosystemand setting up a development environment to creating and publishing Android applications is covered in depth and with technical expertise. Those who crave even more fromthe book will be treated to a feast of useful links at the end of each chapter to help guidethem on and expand their new-found knowledge base.”—Philip Dutson, UX and mobile developer for ICON Health & Fitness“With this edition, you won’t find a more solid and comprehensive introduction to Android programming. Even if you already have another Android book, Introduction to Android Application Development makes a good second reference.”—Douglas Jones, senior software engineer, Fullpower Technologies“Introduction to Android Application Development, Fourth Edition, is an important updateto this invaluable reference for new and seasoned Android developers. It brings the latestup-to-date information about the newest releases of Android, showing you how to keepyour application fresh on yesterday’s, today’s, and tomorrow’s Android devices.”—Ray Rischpater, senior software engineer, Microsoft

This page intentionally left blank

Introductionto Android ApplicationDevelopmentFourth Edition

Developer’s Library SeriesVisit developers-library.com for a complete list of available productsThe Developer’s Library Series from Addison-Wesley providespracticing programmers with unique, high-quality references andtutorials on the latest programming languages and technologies theyuse in their daily work. All books in the Developer’s Library are written byexpert technology practitioners who are exceptionally skilled at organizingand presenting information in a way that’s useful for other programmers.Developer’s Library books cover a wide range of topics, from opensource programming languages and databases, Linux programming,Microsoft, and Java, to Web development, social networking platforms,Mac/iPhone programming, and Android programming.

Introductionto Android ApplicationDevelopmentAndroid EssentialsFourth EditionJoseph Annuzzi, Jr.Lauren DarceyShane ConderUpper Saddle River, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCapetown Sydney Tokyo Singapore Mexico City

Many of the designations used by manufacturers and sellers to distinguish their productsare claimed as trademarks. Where those designations appear in this book, and thepublisher was aware of a trademark claim, the designations have been printed with initialcapital letters or in all capitals.The authors and publisher have taken care in the preparation of this book, but makeno expressed or implied warranty of any kind and assume no responsibility for errors oromissions. No liability is assumed for incidental or consequential damages in connectionwith or arising out of the use of the information or programs contained herein.For information about buying this title in bulk quantities, or for special sales opportunities(which may include electronic versions; custom cover designs; and content particular toyour business, training goals, marketing focus, or branding interests), please contact ourcorporate sales department at corpsales@pearsoned.com or (800) 382-3419.For government sales inquiries, please contact governmentsales@pearsoned.com.For questions about sales outside the U.S., please contact international@pearsoned.com.Visit us on the Web: informit.com/awLibrary of Congress Cataloging-in-Publication DataAnnuzzi, Joseph, Jr.Introduction to Android application development : Android essentials / Joseph Annuzzi,Jr., Lauren Darcey, Shane Conder.—Fourth edition.pages cmRevised edition of first part of: Android wireless application development / ShaneConder, Lauren Darcey. c2010.Includes bibliographical references and index.ISBN-13: 978-0-321-94026-1 (alk. paper)ISBN-10: 0-321-94026-1 (alk. paper)1. Application software—Development. 2. Android (Electronic resource) 3. Mobilecomputing. 4. Wireless communication systems. I. Darcey, Lauren, 1977- II. Conder,Shane, 1975- III. Darcey, Lauren, 1977- Android wireless application development. IV.Title.QA76.76.A65A56 2014005.3—dc232013035917Copyright 2014 Joseph Annuzzi, Jr., Lauren Darcey, and Shane ConderAll rights reserved. Printed in the United States of America. This publication is protectedby copyright, and permission must be obtained from the publisher prior to any prohibitedreproduction, storage in a retrieval system, or transmission in any form or by any means,electronic, mechanical, photocopying, recording, or likewise. To obtain permission touse material from this work, please submit a written request to Pearson Education, Inc.,Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, oryou may fax your request to (201) 236-3290.Some figures that appear in this book have been reproduced from or are modificationsbased on work created and shared by Google and used according to terms describedin the Creative Commons 3.0 Attribution License. See shots of Google products follow these -product-graphics.htmlThe following are registered trademarks of Google:Android , Chromecast , Google Play , Google Wallet , Glass , Google , Nexus ,Google, and the Google logo are registered trademarks of Google Inc.ISBN-13: 978-0-321-94026-1ISBN-10:0-321-94026-1Text printed in the United States on recycled paper at Edwards Brothers Malloy in AnnArbor, Michigan.First printing: November, 2013Editor-in-ChiefMark L. TaubAcquisitions EditorLaura LewinDevelopment EditorSonglin QiuManaging EditorJohn FullerProject EditorCaroline SenayCopy EditorBarbara WoodIndexerJack LewisProofreaderChristine ClarkTechnical ReviewsDouglas JonesRay RischpaterPublishing CoordinatorOlivia BasegioCompositorShepherd, Inc.

This book is dedicated to Cleopatra (Cleo).—Joseph Annuzzi, Jr.This book is dedicated to ESC.—Lauren Darcey and Shane Conder

This page intentionally left blank

Contents at a GlanceAcknowledgments xxxiAbout the Authors xxxiiiIntroduction 1I: An Overview of the Android Platform1 Introducing Android 112 Setting Up Your Android DevelopmentEnvironment 373 Writing Your First Android Application 55II: Android Application Basics4 Understanding the Anatomy of an AndroidApplication 975 Defining Your Application Using the AndroidManifest File 1156 Managing Application Resources 137III: Android User Interface Design Essentials7 Exploring User Interface Building Blocks 1778 Designing with Layouts 2099 Partitioning the User Interface with Fragments 24310 Displaying Dialogs 265IV: Android Application Design Essentials11 Using Android Preferences 28112 Working with Files and Directories 30113 Leveraging Content Providers 31514 Designing Compatible Applications 331

xContents at a GlanceV: Publishing and Distributing Android Applications15 Learning the Android Software DevelopmentProcess 35516 Designing and Developing Bulletproof AndroidApplications 37917 Planning the Android Application Experience 39518 Testing Android Applications 42319 Publishing Your Android Application 459VI: AppendixesA Mastering the Android Development Tools 485B Quick-Start Guide: The Android Emulator 505C Quick-Start Guide: Android DDMS 529D Android IDE and Eclipse Tips and Tricks 547E Answers to Quiz Questions 559Index 567

ContentsAcknowledgments xxxiAbout the Authors xxxiiiIntroduction 1Who Should Read This Book 1Key Questions Answered in This Book 2How This Book Is Structured 2An Overview of Changes in This Edition 3Development Environments Used in This Book 5Supplementary Materials Available 6Where to Find More Information 6Conventions Used in This Book 7Contacting the Authors 7I: An Overview of the Android Platform1 Introducing Android 11A Brief History of Mobile Software Development 11Way Back When 11“The Brick” 13Wireless Application Protocol (WAP) 15Proprietary Mobile Platforms 17The Open Handset Alliance 18Google Goes Wireless 18Forming the Open Handset Alliance 19Manufacturers: Designing Android Devices 19Mobile Operators: Delivering the AndroidExperience 20Apps Drive Device Sales: Developing AndroidApplications 21Taking Advantage of All Android Has to Offer 22The Android Marketplace: Where We Are Now 22Android Platform Differences 23Android: A Next-Generation Platform 23Free and Open Source 25Familiar and Inexpensive Development Tools 25

xiiContentsReasonable Learning Curve for Developers 26Enabling Development of Powerful Applications 26Rich, Secure Application Integration 26No Costly Obstacles for Development 27A “Free Market” for Applications 27A Growing Platform 28The Android Platform 29Android’s Underlying Architecture 29Security and Permissions 31Exploring Android Applications 32Summary36Quiz Questions 36Exercises 36References and More Information 362 Setting Up Your Android DevelopmentEnvironment 37Configuring Your Development Environment 37Configuring Your Operating System for DeviceDebugging 39Configuring Your Android Hardwarefor Debugging 39Upgrading the Android SDK 42Problems with the Android SoftwareDevelopment Kit 42Exploring the Android SDK 43Understanding the Android SDK LicenseAgreement 43Reading the Android SDK Documentation 44Exploring the Core Android ApplicationFramework 45Exploring the Core Android Tools 47Exploring the Android Sample Applications 51Summary52Quiz Questions 52Exercises 53References and More Information 53

Contents3 Writing Your First Android Application 55Testing Your Development Environment 55Adding the Android Samples Using the SDKManager 56Adding the Snake Project to Your Android IDEWorkspace 57Creating an AVD for Your Snake Project 61Creating a Launch Configuration for Your SnakeProject 62Running the Snake Application in the AndroidEmulator 66Building Your First Android Application 68Creating and Configuring a New Android Project 69Core Files and Directories of the AndroidApplication 73Creating an AVD for Your Project 75Creating a Launch Configuration for Your Project 75Running Your Android Application in the Emulator 76Debugging Your Android Application in theEmulator 80Adding Logging Support to Your Android Application 83Adding Some Media Support to Your Application 84Adding Location-Based Services to Your Application 88Debugging Your Application on Hardware 90Summary92Quiz Questions 93Exercises 94References and More Information 94II: Android Application Basics4 Understanding the Anatomy of an AndroidApplication 97Mastering Important Android Terminology 97The Application Context 98Retrieving the Application Context 98Using the Application Context 98Performing Application Tasks with Activities 99The Lifecycle of an Android Activity 100xiii

xivContentsOrganizing Activity Components withFragments 105Managing Activity Transitions with Intents 106Transitioning between Activities with Intents 106Organizing Application Navigation with Activities andIntents 110Working with Services 110Receiving and Broadcasting Intents 111Summary112Quiz Questions 112Exercises 112References and More Information 1135 Defining Your Application Using the AndroidManifest File 115Configuring Android Applications Usingthe Android Manifest File 115Editing the Android Manifest File 116Managing Your Application’s Identity 122Versioning Your Application 122Setting the Application Name and Icon 122Enforcing Application System Requirements 123Targeting Specific SDK Versions 123Enforcing Application Platform Requirements 126Working with External Libraries 128Other Application Configuration Settings andFilters 129Registering Activities in the Android Manifest 129Designating a Primary Entry Point Activity for YourApplication Using an Intent Filter 130Configuring Other Intent Filters 130Registering Other Application Components 131Working with Permissions 131Registering Permissions Your ApplicationRequires 131Registering Permissions Your ApplicationEnforces 132

ContentsExploring Other Manifest File Settings 133Summary133Quiz Questions 134Exercises 134References and More Information 1356 Managing Application Resources 137What Are Resources? 137Storing Application Resources 137Resource Value Types 138Accessing Resources Programmatically 142Setting Simple Resource ValuesUsing the Android IDE 143Working with Different Types of Resources 146Working with String Resources 147Using String Resources as Format Strings 148Working with Quantity Strings 149Working with String Arrays 150Working with Boolean Resources 151Working with Integer Resources 152Working with Colors 152Working with Dimensions 153Drawable Resources 154Working with Images 156Working with Color State Lists 158Working with Animation 159Working with Menus 162Working with XML Files 163Working with Raw Files 164References to Resources 165Working with Layouts 166Referencing System Resources 171Summary172Quiz Questions 173Exercises 173References and More Information 173xv

xviContentsIII: Android User Interface Design Essentials7 Exploring User Interface Building Blocks 177Introducing Android Views and Layouts 177The Android View177The Android Controls 177The Android Layout 178Displaying Text to Users with TextView 179Configuring Layout and Sizing 179Creating Contextual Links in Text 180Retrieving Data from Users with Text Fields 183Retrieving Text Input Using EditText Controls183Constraining User Input with Input Filters 184Helping the User with Autocompletion 186Giving Users Choices Using Spinner Controls188Allowing Simple User Selections with Buttons andSwitches 190Using Basic Buttons 190Using CheckBox and ToggleButtonControls 193Using RadioGroup and RadioButton 194Retrieving Dates, Times, and Numbers from Userswith Pickers 197Using Indicators to Display Progress and Activityto Users 199Indicating Progress with ProgressBar 199Indicating Activity with Activity Bars and ActivityCircles 202Adjusting Progress with Seek Bars 202Other Valuable User Interface Controls 203Displaying Rating Data with RatingBar 204Showing Time Passage with theChronometer 205Displaying the Time 206Summary207Quiz Questions 207Exercises 207References and More Information 208

Contents8 Designing with Layouts 209Creating User Interfaces in Android 209Creating Layouts Using XML Resources 209Creating Layouts Programmatically 211Organizing Your User Interface 214Using ViewGroup Subclasses for LayoutDesign 214Using ViewGroup Subclasses as ViewContainers 214Using Built-in Layout Classes 215Using LinearLayout 217Using RelativeLayout 219Using FrameLayout 222Using TableLayout 224Using GridLayout 228Using Multiple Layouts on a Screen 230Using Container Control Classes 232Using Data-Driven Containers 233Adding Scrolling Support 238Exploring Other View Containers 239Summary239Quiz Questions 239Exercises 240References and More Information 2409 Partitioning the User Interface with Fragments 243Understanding Fragments 243Understanding the Fragment Lifecycle244Working with Special Types of Fragments 247Designing Fragment-Based Applications 248Using the Android Support Package 258Adding Fragment Support to LegacyApplications 259Using Fragments in New Applications Targeting OlderPlatforms 259Linking the Android Support Package to YourProject 260Exploring Nested Fragments 261xvii

xviiiContentsSummary261Quiz Questions 262Exercises 262References and More Information 26310 Displaying Dialogs 265Choosing Your Dialog Implementation 265Exploring the Different Types of Dialogs 266Working with Dialogs and Dialog Fragments 267Tracing the Lifecycle of a Dialog andDialogFragment 268Working with Custom Dialogs 270Working with Support Package Dialog Fragments 271Summary275Quiz Questions 276Exercises 276References and More Information 276IV: Android Application Design Essentials11 Using Android Preferences 281Working with Application Preferences 281Determining When Preferences Are Appropriate 281Storing Different Types of Preference Values 282Creating Private Preferences for Use by a SingleActivity 282Creating Shared Preferences for Use by MultipleActivities 282Searching and Reading Preferences 283Adding, Updating, and Deleting Preferences 284Reacting to Preference Changes 285Finding Preferences Dataon the Android File System 285Creating Manageable User Preferences 286Creating a Preference Resource File 287Using the PreferenceActivity Class 289Organizing Preferences with Headers 291Learning about Cloud Savefor Android Applications 296

ContentsSummary298Quiz Questions 298Exercises 299References and More Information 29912 Working with Files and Directories 301Working with Application Data on a Device 301Practicing Good File Management 302Understanding Android File Permissions 303Working with Files and Directories 303Exploring with the Android ApplicationDirectories 304Working with Other Directories and Fileson the Android File System 309Summary312Quiz Questions 312Exercises 313References and More Information 31313 Leveraging Content Providers 315Exploring Android’s Content Providers 315Using the MediaStore Content Provider 316Using the CallLog Content Provider 318Using the Browser Content Provider 319Using the CalendarContract ContentProvider 321Using the UserDictionary Content Provider 321Using the VoicemailContract ContentProvider 322Using the Settings Content Provider 322Introducing the ContactsContract ContentProviders 322Modifying Content Provider Data 324Adding Records 325Updating Records 326Deleting Records 327Using Third-Party Content Providers 328Summary328Quiz Questions 328xix

xxContentsExercises 329References and More Information 32914 Designing Compatible Applications 331Maximizing Application Compatibility 331Designing User Interfaces for Compatibility 333Working with Fragments 335Leveraging the Android Support Library 335Supporting Specific Screen Types 335Working with Nine-Patch Stretchable Graphics 336Using the “Working Square” Principle 336Providing Alternative Application Resources 338Understanding How Resources Are Resolved 338Organizing Alternative Resources with Qualifiers 339Providing Resources for Different Orientations 345Using Alternative Resources Programmatically 345Organizing Application Resources Efficiently 345Targeting Tablets, TVs, and Other New Devices 347Targeting Tablet Devices 347Targeting Google TV Devices 348Targeting Google Chromecast Devices 350Summary350Quiz Questions 350Exercises 351References and More Information 351V: Publishing and Distributing Android Applications15 Learning the Android Software DevelopmentProcess 355An Overview of the Mobile Development Process 355Choosing a Software Methodology 356Understanding the Dangers of WaterfallApproaches 356Understanding the Value of Iteration 357Gathering Application Requirements 357Determining Project Requirements 357Developing Use Cases for Mobile Applications 360

ContentsIncorporating Third-Party Requirements andRecommendations 360Managing a Device Database 361Assessing Project Risks 364Identifying Target Devices 364Acquiring Target Devices 366Determining the Feasibility of ApplicationRequirements 366Understanding Quality Assurance Risks 367Writing Essential Project Documentation 368Developing Test Plans for Quality AssurancePurposes 368Providing Documentation Required by ThirdParties 369Providing Documentation for Maintenance andPorting 369Leveraging Configuration Management Systems 369Choosing a Source Control System 369Implementing an Application Version System ThatWorks 370Designing Mobile Applications 370Understanding Mobile Device Limitations 370Exploring Common Mobile ApplicationArchitectures 371Designing for Extensibility and Maintenance 371Designing for Application Interoperability 372Developing Mobile Applications 373Testing Mobile Applications 373Controlling the Test Release 374Deploying Mobile Applications 374Determining Target Markets 375Supporting and Maintaining Mobile Applications 375Track and Address Crashes Reported by Users 376Testing Firmware Upgrades 376Maintaining Adequate ApplicationDocumentation 376Managing Live Server Changes 376Identifying Low-Risk Porting Opportunities 376Application Feature Selection 377xxi

xxiiContentsSummary377Quiz Questions 377Exercises 377References and More Information 37816 Designing and Developing Bulletproof AndroidApplications 379Best Practices in Designing BulletproofMobile Applications 379Meeting Mobile Users’ Demands 380Designing User Interfaces for Mobile Devices 380Designing Stable and Responsive MobileApplications 381Designing Secure Mobile Applications 383Designing Mobile Applications for MaximumProfit 383Following the Android Application QualityGuidelines 384Leveraging Third-Party Quality Standards 385Designing Mobile Applications for Easeof Maintenance and Upgrades 385Leveraging Android Tools for Application Design 387Avoiding Silly Mistakes in AndroidApplication Design 388Best Practices in DevelopingBulletproof Mobile Applications 388Designing a Development Process That Worksfor Mobile Development 389Testing the Feasibility of Your Application Early andOften 389Using Coding Standards, Reviews, and Unit Teststo Improve Code Quality 390Handling Defects Occurring on a Single Device 392Leveraging Android Tools for Development 393Avoiding Silly Mistakes in Android ApplicationDevelopment 393Summary393Quiz Questions 394Exercises 394References and More Information 394

Contents17 Planning the Android Application Experience 395Thinking about Objectives 395User Objectives 396Team Objectives 396Objectives of Other Stakeholders 396Techniques for Focusing Your Product Efforts 397Personas 397Entity Discovery and Organization 398Use Cases and Use Case Diagrams 398Charting Your Application’s Navigation 400Android Application Navigation Scenarios 400Launching Tasks and Navigating the BackStack 404Navigating with Fragments 404Planning Application Navigation 404Android Navigation Design Patterns 405Encouraging Action 408Menus410Action Bars 411Dialogs415Actions Originating from Your Application’sContent 416Communicating Your Application’s Identity 416Designing Screen Layouts 417Sketches417Wireframes 417Design Comps 417Reacting Properly with Visual Feedback 418Observing Target Users for Usability 418Mocking Up the Application 418Testing the Release Build 419Summary419Quiz Questions 420Exercises 420References and More Information 420xxiii

xxivContents18 Testing Android Applications 423Best Practices in Testing Mobile Applications 423Designing a Mobile Application Defect-TrackingSystem 423Managing the Testing Environment 425Maximizing Testing Coverage 427Leveraging Android SDK Tools for Android ApplicationTesting 434Avoiding Silly Mistakes in Android ApplicationTesting 435Android Application Testing Essentials 435Unit Testing with JUnit 436Introducing the PasswordMatcherApplication 437Determining What Our Tests Should Prove 441Creating an Android Test Project 441Writing the Tests 447Running Your First Test Using the Android IDE 450Analyzing the Test Results 450Adding Additional Tests 453More Android Automated Testing Programsand APIs 455Summary457Quiz Questions 457Exercises 457References and More Information 45819 Publishing Your Android Application 459Choosing the Right Distribution Model 459Protecting Your Intellectual Property 460Following the Policies of Google Play 461Billing the User 461Packaging Your Application for Publication 462Preparing Your Code for Packaging 463Packing and Signing Your Application 465Testing the Release Version of Your ApplicationPackage 467Including All Required Resources 467

ContentsReadying Your Servers or Services 467Distributing Your Application 467Publishing to Google Play 468Signing Up for Publishing to Google Play 468Uploading Your Application to Google Play 471Uploading Application Marketing Assets 473Configuring Pricing and Distribution Details 474Configuring Additional Application Options 475Managing Other Developer Console Options 476Publishing Your Application to Google Play 476Managing Your Application on Google Play 476Google Play Staged Rollouts 478Publishing to the Google Play Private Channel 478Translating Your Application 478Publishing Using Other Alternatives 479Self-Publishing Your Application 479Summary480Quiz Questions 481Exercises 481References and More Information 481VI: AppendixesA Mastering the Android Development Tools 485Using the Android Documentation 485Leveraging the Android Emulator 489Viewing Application Log Data with LogCat 490Debugging Applications with DDMS490Using Android Debug Bridge (ADB) 490Using the Resource Editors and UI Designer 491Using the Android Hierarchy Viewer 493Launching the Hierarchy Viewer 494Working in Layout View Mode 495Optimizing Your User Interface 496Working in Pixel Perfect Mode 497Working with Nine-Patch Stretchable Graphics 497Working with Other Android Tools 500xxv

xxviContentsSummary502Quiz Questions 503Exercises 503References and More Information 503B Quick-Start Guide: The Android Emulator 505Simulating Reality: The Emulator’s Purpose 505Working with Android Virtual Devices 507Using the Android Virtual Device Manager 508Creating an AVD 509Creating AVDs with Custom Hardware Settings 510Launching the Emulator with a Specific AVD 512Maintaining Emulator Performance 512Configuring Emulator Startup Options 513Launching an Emulator to Run an Application 513Launching an Emulator from the Android VirtualDevice Manager 515Configuring the GPS Location of the Emulator 516Calling between Two Emulator Instances 517Messaging between Two Emulator Instances 518Interacting with the Emulatorthrough the Console 520Using the Console to Simulate Incoming Calls 521Using the Console to Simulate SMS Messages 522Using the Console to Send GPS Coordinates 523Using the Console to Monitor Network Status 523Using the Console to Manipulate PowerSettings 523Using Other Console Commands 524Enjoying the Emulator 524Understanding Emulator Limitations 525Summary526Quiz Questions 526Exercises 527References and More Information 527C Quick-Start Guide: Android DDMS 529Using DDMS with the Android IDEand as a Standalone Application 529

ContentsGetting Up to Speed Using Key Features of DDMS530Working with Processes, Threads, and the Heap 531Attaching a Debugger to an Android Application 531Stopping a Process 532Monitoring Thread Activity of an AndroidApplication 532Monitoring Heap Activity 532Prompting Garbage Collection 534Creating and Using an HPROF File534Using the Allocation Tracker 534Viewing Network Statistics 535Working with the File Explorer 536Browsing the File System of an Emulator orDevice 536Copying Files from the Emulator or Device 538Copying Files to the Emulator or Device 539Deleting Files on the Emulator or Device 539Working with the Emulator Control 539Change Telephony Status 540Simulating Incoming Voice Calls 540Simulating Incoming SMS Messages 540Sending a Location Fix 541Working with the System Information PaneTaking Screen Captures of the Emulatorand Device Screens 542Working with Application Logging 543Summary544Quiz Questions 545Exercises 545References and More Information 545D Android IDE and Eclipse Tips and Tricks 547Organizing Your Android IDE Workspace 547Integrating with Source Control Services 547Repositioning Tabs within Perspectives 548Maximizing Windows 548Minimizing Windows 548Viewing Windows Side by Side 548541xxvii

xxviiiContentsViewing Two Sections of the Same File 550Closing Unwanted Tabs 550Keeping Windows under Control 550Creating Custom Log Filters 551Searching Your Project 551Organizing Android IDE Tasks 551Writing Code in Java 552Using Autocomplete 552Creating New Classes and Methods 552Organizing Imports 553Formatting Code 553Renaming Almost Anything 553Refactoring Code 554Reorganizing Code 555Using QuickFix 555Providing Javadoc-Style Documentation 556Resolving Mysterious Build Errors 556Summary557Quiz Questions 557Exercises 557References and More Information 557E Answers to Quiz Questions 559Chapter 1: Introducing Android 559Chapter 2: Setting Up Your AndroidDevelopment Environment 559Chapter 3: Writing Your First Android Application 559Chapter 4: Android Application Basics 560Chapter 5: Defining Your Application Using the AndroidManifest File 560Chapter 6: Managing Application Resources 560Chapter 7: Exploring User Interface Building Blocks 561Chapter 8: Designing with Layouts 561Chapter 9: Partitioning the User Interface withFragments 561Chapter 10: Displaying Dialogs 562Chapter 11: Using Android Preferences 562Chapter 12: Working with Files and Directories 562

ContentsChapter 13: Leveraging Content Providers 562Chapter 14: Designing Compatible Applications 563Chapter 15: Learning the Android Software DevelopmentProcess 563Chapter 16: Designing and Developing BulletproofAndroid Applications 563Chapter 17: Planning the Android ApplicationExperience 564Chapter 18: Testing Android Applications 564Chapter 19: Publishing Your Android Application 564Appendix A: Mastering the Android DevelopmentTools 565Appendix B: Quick-Start Guide: The AndroidEmulator 565Appendix C: Quick-Start Guide: Android DDMSAppendix D: Android IDE and Eclipse Tipsand Tricks 566Index 567565xxix

This page intentionally left blank

AcknowledgmentsThis book is the result of collaboration among a great group, from the efforts of the teamat Pearson Education (Addison-Wesley Professional); from the suggestions made by thetechnical reviewers; and from the support of family, friends, coworkers, and acquaintancesalike. We’d like to thank the Android developer community, Google, and the OpenHandset Alliance for their vision and expertise. Special thanks go to Mark Taub for believing in the vision for this edition; Laura Lewin, who was the driving force behind thebook and without whom

droid programming. Even if you already have another Android book, Introduction to An-droid Application Development makes a good second reference.” —Douglas Jones, senior software engineer, Fullpower Technologies “Introduction to Android Applic