Home > Store

Learning Android Application Programming for the Kindle Fire: A Hands-On Guide to Building Your First Android Application

Register your product to gain access to bonus material or receive a coupon.

Learning Android Application Programming for the Kindle Fire: A Hands-On Guide to Building Your First Android Application

eBook (Watermarked)

  • Sorry, this book is no longer in print.
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Not for Sale


  • Copyright 2012
  • Dimensions: 7" x 9"
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-303885-8
  • ISBN-13: 978-0-13-303885-9

Master Android™ App Development for Amazon’s Bestselling Kindle Fire™—Hands-On, Step-by-Step!

In this book, bestselling Android programming authors Lauren Darcey and Shane Conder teach you every skill and technique you need to write production-quality apps for Amazon Kindle Fire, the world’s hottest Android tablet. You’ll learn the very best way: by building a complete app from start to finish. Every chapter builds on what you’ve already learned, helping you construct, expand, and extend your working app as you move through the entire development lifecycle.

Packed with fully tested, reusable sample code, this book requires absolutely no previous Android or mobile development experience. If you’ve ever written any Java code, you can dive right in and get results fast. Darcey and Conder start with the absolute basics: installing Android development tools, structuring and configuring Kindle Fire apps, and applying crucial design principles associated with high-quality software. Next, building on this strong foundation, you’ll learn how to manage application resources and build application frameworks; integrate user interfaces, logic, and support for networking and web services; test your apps; and publish on the Amazon Appstore.

Coverage includes

  • Establishing an efficient development environment and setting up your first project
  • Mastering Android fundamentals and adapting them to the Kindle Fire
  • Building reusable prototypes that define a framework for production projects
  • Incorporating strings, graphics, styles, templates, and other app and system resources
  • Developing screens, from splash screens and main menus to settings and help
  • Displaying dialogs and collecting user input
  • Controlling app state, saving settings, and launching specific activities
  • Internationalizing Kindle Fire apps to reach wider markets
  • Setting application identity and permissions
  • Preparing your app for publication

Sample Content

Table of Contents

Introduction     1

I:  Kindle Fire Fundamentals

1  Getting Started with Kindle Fire     9

Introducing Android     9

  Google and the Open Handset Alliance     9

  Android Makes Its Entrance     10

  Cheap and Easy Development     10

Familiarizing Yourself with Eclipse     12

  Creating Android Projects     13

  Exploring Your Android Project Files     16

  Editing Project Resources     17

Running and Debugging Applications     20

  Managing Android Virtual Devices     20

  Creating Debug and Run Configurations in Eclipse     22

  Launching Android Applications Using the Emulator     22

  Debugging Android Applications Using DDMS     25

  Launching Android Applications on a Device     25

Summary     28

Exercises     28

2  Mastering the Android Development Tools     29

Using the Android Documentation     29

Debugging Applications with DDMS     31

  Managing Tasks     32

  Browsing the Android File System     33

  Taking Screenshots of the Emulator or Device     34

  Viewing Log Information     35

Working with the Android Emulator     36

  Providing Input to the Emulator     36

Using Other Android Tools     36

Summary     36

3  Building Kindle Fire Applications     39

Designing an Android Application     39

  Designing Application Features     40

  Determining Application Activity Requirements     40

  Implementing Application Functionality     41

Using the Application Context     42

  Retrieving Application Resources     42

  Accessing Application Preferences     42

  Accessing Other Application Functionality Using Contexts     43

Working with Activities     43

  Launching Activities     43

  Managing Activity State     44

  Shutting Down Activities     45

Working with Intents     46

  Passing Information with Intents     47

  Using Intents to Launch Other Applications     47

Working with Dialogs     48

Working with Fragments     49

Logging Application Information     50

Summary     51

Exercises     51

4  Managing Application Resources     53

Using Application and System Resources     53

  Working with Application Resources     53

  Working with System Resources     56

Working with Simple Resource Values     57

  Working with Strings     57

  Working with Colors     57

  Working with Dimensions     58

Working with Drawable Resources     59

  Working with Images     59

  Working with Other Types of Drawables     60

Working with Layouts 60

  Designing Layouts Using the Layout Resource Editor     61

  Designing Layouts Using XML     62

Working with Files     64

  Working with XML Files     64

  Working with Raw Files     65

  Working with Other Types of Resources     66

Summary     66

Exercises     66

5  Configuring the Android Manifest File     69

Exploring the Android Manifest File     69

  Using the Manifest Tab     70

  Using the Application Tab     71

  Using the Permissions Tab     71

  Using the Instrumentation Tab     72

  Using the AndroidManifest.xml Tab     73

Configuring Basic Application Settings     73

  Naming Android Packages     74

  Versioning an Application     74

  Setting the Minimum Android API Version     75

  Naming an Application     76

  Providing an Icon for an Application     76

  Providing an Application Description     76

  Setting Debug Information for an Application     77

  Setting Other Application Attributes     77

Defining Activities     77

  Registering Activities     77

  Designating the Launch Activity     78

Managing Application Permissions     79

Managing Other Application Settings     81

Summary     81

Exercises     81

6  Designing an Application Framework     83

Designing an Android Trivia Game     83

  Determining High-Level Game Features      83

  Determining Activity Requirements     84

  Determining Screen-Specific Game Features     85

Implementing an Application Prototype     90

  Reviewing the Accompanying Source Code     90

  Creating a New Android Project     90

  Adding Project Resources     91

  Implementing Application Activities     92

  Creating Application Preferences     93

Running the Game Prototype     95

  Creating a Debug Configuration     95

  Launching the Prototype in the Emulator     95

  Exploring the Prototype Installation     96

Summary     97

Exercises     97

II:  Building an Application Framework

7  Implementing an Animated Splash Screen     101

Designing the Splash Screen     101

Implementing the Splash Screen Layout     102

  Adding New Project Resources     103

  Updating the Splash Screen Layout     106

Working with Animation     110

  Adding Animation Resources     110

  Animating Specific Views     112

  Setting the Image Animations     113

  Handling Animation Lifecycle Events     114

Summary     115

Exercises     116

8 Implementing the Main Menu Screen     117

Designing the Main Menu Screen     117

  Determining Main Menu Screen Layout Requirements     118

  Designing the Screen Header     118

  Designing the GridView Control     118

  Finishing Touches for the Main Menu Layout Design     119

Implementing the Main Menu Screen Layout     119

  Adding New Project Resources    120

  Updating the Main Menu Screen Layout Files     121

Working with the GridView Control     124

  Filling a GridView Control      124

  Listening for GridView Events     127

Working with Other Menu Types     128

  Adding an Options Menu to the Game Screen     129

Summary     131

Exercises     131

9 Developing the Help and Scores Screens     133

Designing the Help Screen     133

Implementing the Help Screen Layout     135

  Adding New Project Resources     135

  Updating the Help Screen Layout     135

Working with Files     136

  Adding Raw Resource Files     136

  Accessing Raw File Resources     137

Designing the Scores Screen     138

  Determining Scores Screen Layout Requirements     138

  Adding the TabHost Control     139

Implementing the Scores Screen Layout     141

  Adding New Project Resources     141

  Updating the Scores Screen Layout     142

Building a Screen with Tabs     144

  Configuring the TabHost Control     144

  Adding Tabs to the TabHost Control     145

  Setting the Default Tab     145

Working with XML     146

  Retrieving XML Resources     146

  Parsing XML Files with XmlResourceParser     146

  Applying Finishing Touches to the Scores Screen     147

Summary     148

Exercises     148

10  Collecting User Input     149

Designing the Settings Screen     149

Implementing the Settings Screen Layout     151

  Adding New Project Resources 151

  Updating the Settings Screen Layout     154

Using Common Form Controls     155

  Working with EditText Controls     156

  Working with Spinner Controls     159

Saving Form Data with SharedPreferences     161

  Defining SharedPreferences Entries     161

  Saving Settings to SharedPreferences     161

  Reading Settings from SharedPreferences     162

Summary     163

11  Using Dialogs to Collect User Input     165

Working with Activity Dialogs     165

  Exploring the Different Types of Dialogs     166

  Tracing the Lifecycle of a Dialog     167

Using the DatePickerDialog Class     168

  Adding a DatePickerDialog to a Class     168

  Initializing a DatePickerDialog     170

  Launching DatePickerDialog     170

Working with Custom Dialogs     171

  Adding a Custom Dialog to the Settings Screen     172

Summary     178

Exercises     178

12  Adding Application Logic     181

Designing the Game Screen     181

Implementing the Game Screen Layout     183

  Adding New Project Resources     184

  Updating the Game Screen Layout     185

Working with ViewSwitcher Controls     186

  Initializing Switcher Controls     187

  Implementing Switcher Factory Classes     187

  Updating the TextSwitcher Control     189

  Updating the ImageSwitcher Control     189

Wiring Up Game Logic     190

  Adding Game State Settings to the SharedPreferences     191

  Retrieving, Parsing, and Storing Book Data     192

Summary     197

Exercises     197

13  Adding Network Support     199

Designing Network Applications     199

  Working with an Application Server     199

  Managing Lengthy Network Operations     200

  Informing the User of Network Activity     201

Developing Network Applications     201

  Enabling Network Testing on the Emulator     202

  Testing Network Applications on Kindle Fire     202

Accessing Network Services     202

  Planning Have You Read That? Network Support     202

  Setting Network Permissions     203

  Checking Network Status     203

  Using HTTP Networking     203

Indicating Network Activity with Progress Bars     204

  Displaying Indeterminate Progress     204

  Displaying Determinate Progress     204

  Displaying Progress Dialogs     204

Running Tasks Asynchronously     206

  Using AsyncTask     206

  Using Threads and Handlers     207

Downloading and Displaying Score Data     207

  Extending AsyncTask for Score Downloads     207

  Starting the Progress Indicator with onPreExecute()     208

  Clearing the Progress Indicator with onPostExecute()     209

  Handling Cancellation with onCancelled()     209

  Handling Processing with doInBackground()     210

  Handling Progress Updates with onProgressUpdate()     211

  Starting the ScoreDownloaderTask     212

Downloading and Parsing Batches of Books     213

  Extending AsyncTask for Book Downloads     213

  Starting the Progress Dialog with onPreExecute()     214

  Dismissing the Progress Dialog with onPostExecute()     214

  Handling the Background Processing     215

  Starting the BookListDownloaderTask     215

Determining What Data to Send to the Server     216

Keeping Player Data in Sync     216

Uploading Settings Data to a Remote Server     217

  Working with Android Services     218

  Implementing UploadTask     220

  Uploading Player Data with the HTTP GET Method     220

Uploading Score Data to a Remote Server     223

Downloading Friends’ Score Data      224

Summary     224

Exercises     224

14  Exploring the Amazon Web Services SDK for Android     225

The 10,000-Foot View of AWS     225

Exploring the AWS Offerings     226

  Using AWS Database and Storage Services     227

  Using AWS Messaging and Notification Services     227

  Using AWS Infrastructure and Administrative Services     228

Summary     228

Exercises     228

III:  Publishing Your Kindle Fire Application

15  Managing Alternative and Localized Resources     233

Using the Alternative Resource Hierarchy     233

  Understanding How Resources Are Resolved     234

  Organizing Alternative Resources with Qualifiers     234

  Using Alternative Resources Programmatically     236

  Organizing Application Resources Efficiently     236

Customizing the Application Experience     237

  Updating the Main Screen     237

  Updating the Splash Screen     238

  Updating the Game Screen     239

  Updating the Other Screens     240

Internationalizing Android Applications     240

How Android Localization Works     241

  How the Android Operating System Handles Locale     241

  How Applications Handle Locales     241

  How Kindle Fire Handles Locales     243

Android Internationalization Strategies     243

  Forgoing Application Internationalization     244

  Limiting Application Internationalization     245

  Implementing Full Application Internationalization     245

Using Localization Utilities     246

  Determining System Locale     246

  Formatting Strings Like Dates and Times     246

  Handling Currencies     247

Summary     247

Exercises     247

16  Testing Kindle Fire Applications     249

Testing Best Practices     249

  Developing Coding Standards     250

  Performing Regular Versioned Builds     250

  Using a Defect Tracking System     251

  Developing Good Test Plans     251

Maximizing Test Coverage     252

  Testing on the Emulator     252

  Testing on Target Devices     253

  Performing Automated Testing     253

Summary     260

Exercises     260

17  Registering as an Amazon Application Developer     261

Understanding the Release Process     261

Preparing the Release Candidate Build     263

  Preparing the Android Manifest File for Release     263

  Protecting Your Application from Software Pirates     264

  Readying Related Services for Release     265

Testing the Application Release Candidate     265

Signing Up as an Amazon App Developer     266

Packaging and Signing an Application     267

  Digitally Signing Applications     267

  Exporting and Signing the Package File     267

Testing the Signed Application Package     268

  Installing the Signed Application Package     269

  Verifying the Signed Application     269

Summary     270

Exercises     270

18  Publishing Applications on the Amazon Appstore     271

Selling on the Amazon Appstore     271

  Signing Up for a Developer Account     271

  Complying with the Developer License Agreement     272

  Uploading an Application     272

  Understanding Amazon Appstore Royalties     273

  Using Other Developer Account Benefits     273

  Generating Reports     274

Summary     274

Exercises     274

IV:  Appendixes

A  Configuring Your Android Development Environment     279

Configuring Your Development Environment     279

Development Machine Prerequisites     280

Installing the Java Development Kit     281

Installing the Eclipse IDE     281

Installing the Android SDK     281

Installing and Configuring the Android Plug-In for Eclipse (ADT)     282

Downloading Android SDK Components     282

Upgrading the Android SDK and Tools     284

Debugging with the Amazon Kindle Fire     284

Configuring Other Android Devices for Development Purposes     286

B  Eclipse IDE Tips and Tricks     289

Organizing Your Eclipse Workspace     289

Writing Code in Java     293

C  Supplementary Materials     299

Using the Source Code for This Book     299

Accessing the Android Developer Website     300

Accessing the Publisher‘s Website     300

Accessing the Authors‘ Website     301

Contacting the Authors     303

Leveraging Online Android Resources     304

Index     305


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020