O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Android™ for Programmers: An App-Driven Approach, Second Edition

Book Description

The professional programmer’s Deitel® guide to smartphone and tablet app development using Android 4.3 and 4.4, the Eclipse-based Android Development Tools and the new Android Studio

Billions of apps have been downloaded from Google Play™! This book gives you everything you’ll need to start developing great Android apps quickly and getting them published on Google Play™. The book uses an app-driven approach–each new technology is discussed in the context of seven fully tested Android apps, complete with syntax coloring, code highlighting, code walkthroughs and sample outputs. Apps you’ll develop include:

Welcome App Cannon Game Tip Calculator Doodlz Twitter® Searches Address Book Flag Quiz

The first-generation Android phones were released in October 2008. By October 2013, a Strategy Analytics report showed that Android had 81.3% of the global smartphone market share, compared to 13.4% for Apple, 4.1% for Microsoft and 1% for Blackberry (bit.ly/1aqIZXf). Billions of apps have been downloaded from Google Play. There are now more than one billion activated Android devices worldwide and more than 1.5 million Android devices are being activated daily (venturebeat.com/2013/09/03/android-hits-1bactivations-and-will-be-called-kitkat-in-nextversion). The opportunities for Android app developers are enormous.

This book presents leading-edge computing technologies for professional software developers. At the heart of the book is the Deitel “app-driven approach”–concepts are presented in the context of complete working Android apps, rather than using code snippets. The introduction and app test drives at the beginning of each chapter show one or more sample executions. The book’s source code is available at www.deitel.com/books/androidfp2.

The apps in this book were carefully designed to introduce you to key Android features and APIs. You’ll quickly learn everything you need to start building Android apps–beginning with a testdrive of the Doodlz app in Chapter 1, then building your first app in Chapter 2. By the time you reach Chapter 9, you’ll be ready to create your own apps for submission to Google Play and other app marketplaces. You’ll master the Google Play submission process, including uploading your apps, deciding whether to sell your apps or offer them for free, and marketing them using in-app advertising, social media, Internet public relations and more.

Practical, example-rich coverage of:

Android 4.3 and 4.4 Android Development Tools, Android Studio Supporting Various Screen Sizes/Resolutions Accessibility, Internationalization, Graphics Activities, Fragments, Intents, Preferences GUIs, Layouts, Menus, Resource Files, Lists, Adapters, Events, Touch/Gesture Processing Immersive Mode, Printing Framework, PrintHelper Assets (Images, Audio), View Animation Threading, Collections, SQLite Database Social sharing via implicit intents Google Play™, App Publishing, Pricing, Monetization, Marketing, In-App Advertising, In-App Billing and more.

Visit www.deitel.com

Download code examples For information on Deitel’s Dive Into® Series programming training courses delivered at organizations worldwide visit www.deitel.com/training or write to deitel@deitel.com Join the Deitel social networking communities on Facebook® at deitel.com/DeitelFan, Twitter® @deitel, Google+™ at google.com/+DeitelFan, LinkedIn® at bit.ly/DeitelLinkedIn, YouTube™ at youtube.com/user/DeitelTV and subscribe to the Deitel® Buzz Online e-mail newsletter at www.deitel.com/newsletter/ subscribe.html

The Deitel® Developer Series is designed for professional programmers. The series presents focused treatments on a growing list of emerging and mature technologies, including Android™ app development, iOS® app development, Java™, C# and .NET, C++, C, JavaScript®, Internet and web development and more. Each book in the series contains the same live-code teaching methodology used in the Deitels’ How to Program Series college textbooks–most concepts are presented in the context of completely coded, working apps.

Deitel & Associates is an internationally recognized authoring and corporate training organization specializing in Android™ and iOS® app development, programming languages, object technology and Internet and web software technology. The company offers instructor-led courses delivered at client sites worldwide on programming languages and platforms, such as Android™ app development, iOS® app development, Java™, Objective-C, C#, Visual Basic®, Visual C++®, C++, C, XML, Python, Perl®, object technology, Internet and web programming, and a growing list of additional programming and software-development courses. The founders of Deitel & Associates, Inc., are Paul Deitel and Dr. Harvey Deitel. The company’s training clients include many of the world’s largest corporations, government agencies, branches of the military and academic institutions. To learn more about Deitel & Associates, Inc., its professional books, college textbooks, e-books and LiveLessons video training, and its worldwide Dive-Into® Series instructor-led, on-site training curriculum, visit www.deitel.com/training or send an email to deitel@deitel.com. Join the Deitel social media communities on Facebook® (www.deitel.com/DeitelFan), Twitter® (@deitel), Google+™ (google.com/+DeitelFan), LinkedIn® (bit.ly/DeitelLinkedIn) and YouTube™ (youtube.com/user/DeitelTV), and subscribe to the Deitel® Buzz Online newsletter (www.deitel.com/newsletter/subscribe.html).

Table of Contents

  1. About This eBook
  2. Title Page
  3. Copyright Page
  4. Dedication Page
  5. Contents
  6. Preface
    1. Copyright Notice and Code License
    2. Intended Audience
    3. Key Features
    4. Features
    5. Working with Open-Source Apps
    6. Android for Programmers: An App-Driven Approach, Second Edition, Volume 2
    7. Android Fundamentals, Second Edition LiveLessons Video Training Products
    8. Join the Deitel & Associates, Inc. Social Networking Communities
    9. Contacting the Authors
    10. Visit www.deitel.com to:
    11. Acknowledgments
    12. Reviewers of the Content from Android for Programmers: An App-Driven Approach and Android How to Program Recent Editions
    13. About the Authors
    14. Deitel® Dive-Into® Series Corporate Training
  7. Before You Begin
    1. Font and Naming Conventions
    2. Software and Hardware System Requirements
    3. Installing the Java Development Kit (JDK)
    4. Android Integrated Development Environment (IDE) Options
    5. Installing the Android SDK/ADT Bundle
    6. Installing Android Studio
    7. Set the Java Compiler Compliance Level and Show Line Numbers
    8. Android 4.3 SDK
    9. Creating Android Virtual Devices (AVDs)
    10. (Optional) Setting Up an Android Device for Development
    11. Obtaining the Book’s Code Examples
    12. A Note Regarding the Android Development Tools
  8. 1. Introduction to Android
    1. 1.1. Introduction
    2. 1.2. Android—The World’s Leading Mobile Operating System
    3. 1.3. Android Features
    4. 1.4. Android Operating System
    5. 1.5. Downloading Apps from Google Play
    6. 1.6. Packages
    7. 1.7. Android Software Development Kit (SDK)
    8. 1.8. Object-Oriented Programming: A Quick Refresher
    9. 1.9. Test-Driving the Doodlz App in an Android Virtual Device (AVD)
    10. 1.10. Building Great Android Apps
    11. 1.11. Android Development Resources
    12. 1.12. Wrap-Up
  9. 2. Welcome App
    1. 2.1. Introduction
    2. 2.2. Technologies Overview
    3. 2.3. Creating an App
    4. 2.4. Android Developer Tools Window
    5. 2.5. Building the App’s GUI with the Graphical Layout Editor
    6. 2.6. Running the Welcome App
    7. 2.7. Making Your App Accessible
    8. 2.8. Internationalizing Your App
    9. 2.9. Wrap-Up
  10. 3. Tip Calculator App
    1. 3.1. Introduction
    2. 3.2. Test-Driving the Tip Calculator App
    3. 3.3. Technologies Overview
    4. 3.4. Building the App’s GUI
    5. 3.5. Adding Functionality to the App
    6. 3.6. AndroidManifest.xml
    7. 3.7. Wrap-Up
  11. 4. Twitter® Searches App
    1. 4.1. Introduction
    2. 4.2. Test-Driving the App
    3. 4.3. Technologies Overview
    4. 4.4. Building the App’s GUI
    5. 4.5. Building the MainActivity Class
    6. 4.6. AndroidManifest.xml
    7. 4.7. Wrap-Up
  12. 5. Flag Quiz App
    1. 5.1. Introduction
    2. 5.2. Test-Driving the Flag Quiz App
    3. 5.3. Technologies Overview
    4. 5.4. Building the GUI and Resource Files
    5. 5.5. MainActivity Class
    6. 5.6. QuizFragment Class
    7. 5.7. SettingsFragment Class
    8. 5.8. SettingsActivity Class
    9. 5.9. AndroidManifest.xml
    10. 5.10. Wrap-Up
  13. 6. Cannon Game App
    1. 6.1. Introduction
    2. 6.2. Test-Driving the Cannon Game App
    3. 6.3. Technologies Overview
    4. 6.4. Building the App’s GUI and Resource Files
    5. 6.5. Class Line Maintains a Line’s Endpoints
    6. 6.6. MainActivity Subclass of Activity
    7. 6.7. CannonGameFragment Subclass of Fragment
    8. 6.8. CannonView Subclass of View
    9. 6.9. Wrap-Up
  14. 7. Doodlz App
    1. 7.1. Introduction
    2. 7.2. Technologies Overview
    3. 7.3. Building the App’s GUI and Resource Files
    4. 7.4. MainActivity Class
    5. 7.5. DoodleFragment Class
    6. 7.6. DoodleView Class
    7. 7.7. ColorDialogFragment Class
    8. 7.8. LineWidthDialogFragment Class
    9. 7.9. EraseImageDialogFragment Class
    10. 7.10. Wrap-Up
  15. 8. Address Book App
    1. 8.1. Introduction
    2. 8.2. Test-Driving the Address Book App
    3. 8.3. Technologies Overview
    4. 8.4. Building the GUI and Resource Files
    5. 8.5. MainActivity Class
    6. 8.6. ContactListFragment Class
    7. 8.7. AddEditFragment Class
    8. 8.8. DetailsFragment Class
    9. 8.9. DatabaseConnector Utility Class
    10. 8.10. Wrap-Up
  16. 9. Google Play and App Business Issues
    1. 9.1. Introduction
    2. 9.2. Preparing Your Apps for Publication
    3. 9.3. Pricing Your App: Free or Fee
    4. 9.4. Monetizing Apps with In-App Advertising
    5. 9.5. Monetizing Apps: Using In-App Billing to Sell Virtual Goods
    6. 9.6. Registering at Google Play
    7. 9.7. Setting Up a Google Wallet Merchant Account
    8. 9.8. Uploading Your Apps to Google Play
    9. 9.9. Launching the Play Store from Within Your App
    10. 9.10. Managing Your Apps in Google Play
    11. 9.11. Other Android App Marketplaces
    12. 9.12. Other Popular Mobile App Platforms
    13. 9.13. Marketing Your Apps
    14. 9.14. Wrap-Up
  17. Index