Introduction to Android Application Development Android Essentials.pdf - About This E-Book EPUB is an open industry-standard format for e-books However

Introduction to Android Application Development Android Essentials.pdf

This preview shows page 1 out of 1035 pages.

You've reached the end of your free preview.

Want to read all 1035 pages?

Unformatted text preview: About This E-Book EPUB is an open, industry-standard format for e-books. However, support for EPUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site. Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the e-book in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “Click here to view code image” link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app. Introduction to Android™ Application Development Android Essentials Fifth Edition Joseph Annuzzi, Jr. Lauren Darcey Shane Conder Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City Sao Paulo • Sidney • Hong Kong • Seoul • Singapore • Taipei • Tokyo Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with 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 to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected] For questions about sales outside the U.S., please contact [email protected] Visit us on the Web: informit.com/aw Library of Congress Cataloging-in-Publication Data Names: Annuzzi, Joseph, Jr., author. | Darcey, Lauren, 1977- author. | Conder, Shane, 1975- author. Title: Introduction to Android application development : Android essentials / Joseph Annuzzi, Jr., Lauren Darcey, Shane Conder. Description: Fifth edition | New York : Addison-Wesley, [2016] | Includes bibliographical references and index. Identifiers: LCCN 2015037913 | ISBN 9780134389455 (pbk. : alk. paper) Subjects: LCSH: Application software—Development. | Android (Electronic resource) | Mobile computing. | Wireless communication systems. Classification: LCC QA76.76.A65 A56 2016 | DDC 005.3—dc23 LC record available at Copyright © 2016 Joseph Annuzzi, Jr., Lauren Darcey, and Shane Conder All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit . Some figures that appear in this book have been reproduced from or are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 3.0 Attribution License ( ). Some figures that appear in this book have been reproduced from or are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 3.0 License. See . Screenshots of Google Products follow these guidelines: The following are registered trademarks of Google: Android™, Chrome™, Google Play™, Nexus™, Dalvik™, Google Maps™, Google+™, Google TV™, Google and the Google logo are registered trademarks of Google Inc. ARM is a registered trademark of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. Altium® and Altium Designer® are trademarks or registered trademarks of Altium Limited or its subsidiaries. Qualcomm and Snapdragon are trademarks of Qualcomm Incorporated, registered in the United States and other countries. Cyanogen is a trademark of Cyanogen Inc., registered in certain countries. CyanogenMod is a trademark of CyanogenMod, LLC, registered in the United States. JetBrains® and IntelliJ®, are registered trademarks owned by JetBrains s.r.o. ISBN-13: 978-0-13-438945-5 ISBN-10: 0-13-438945-X Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing December 2015 Editor-in-Chief Mark L. Taub Executive Editor Laura Lewin Development Editor Songlin Qiu Managing Editor John Fuller Senior Project Editor Kesel Wilson Copy Editor Deborah Thompson Indexer Jack Lewis Proofreader Sue Boshers Technical Reviewers Douglas Jones Ray Rischpater Valerie Shipbaugh Editorial Assistant Olivia Basegio Cover Designer Chuti Prasertsith Compositor codeMantra Praise for Introduction to Android™ Application Development, Fifth Edition “Introduction to Android Application Development is a great resource for developers who want to understand Android app development but who have little or no experience with mobile software. This fifth edition has a bunch of great changes, from using Android Studio to understanding and implementing navigation patterns, and each chapter has quiz questions to help make sure you’re picking up the vital info that fills this book.” —Ian G. Clifton, author of Android User Interface Design “Revamped, revitalized, and refreshed! Introduction to Android Application Development, Fifth Edition, is a wonderful upgrade to an already impressive compendium. Common pitfalls are explained, new features are covered in depth, and the knowledge that the book is geared to cover everything from introduction of a concept to learning how to implement it into your app makes this a great choice for new developers who are ready to make the jump into Android development. Being already accustomed to the professional work and experience that Annuzzi et al., bring to the table, you will be grateful to have expert insight along with the care and instruction that developers of all skill levels can benefit from.” —Phil Dutson, solution architect, ICON Health & Fitness “Best technical summary of Material Design implementation I’ve seen outside the Android sample docs.” —Ray Rischpater, software development manager, Uber “Introduction to Android Application Development is well written and fulfills the requirements of developers, project managers, educators, and entrepreneurs in developing fully featured Android applications. In addition, it emphasizes quality assurance for mobile applications, teaches you how to design and plan your Android application, and teaches the software development process through a step-by-step, easy-to-understand approach. I recommend this book to anyone who wants to not just focus on developing apps, but also to apply tips and tricks and other tools for project management in their development of successful applications.” —Bintu Harwani, founder of MCE (Microchip Computer Education) This book is dedicated to Cleopatra (Cleo). —Joseph Annuzzi, Jr. This book is dedicated to ESC. —Lauren Darcey and Shane Conder Contents at a Glance Acknowledgments About the Authors Introduction I: Platform Overview 1 Presenting Android 2 Setting Up for Development 3 Creating Your First Application II: Application Basics 4 Understanding Application Components 5 Defining the Manifest 6 Managing Application Resources 7 Exploring Building Blocks 8 Positioning with Layouts 9 Partitioning with Fragments III: Application Design Essentials 10 Architecting with Patterns 11 Appealing with Style 12 Embracing Material Design 13 Designing Compatible Applications IV: Application Development Essentials 14 Using Android Preferences 15 Accessing Files and Directories 16 Saving with SQLite 17 Leveraging Content Providers V: Application Delivery Essentials 18 Learning the Development Workflow 19 Planning the Experience 20 Delivering Quality Applications 21 Testing Your Applications 22 Distributing Your Applications VI: Appendixes A Tips and Tricks: Android Studio B Quick-Start: Android Emulator C Quick-Start: Android Device Monitor D Mastery: Android SDK Tools E Quick-Start: Gradle Build System F Answers to Quiz Questions Index Contents Acknowledgments About the Authors Introduction Who Should Read This Book Key Questions Answered in This Book How This Book Is Structured An Overview of Changes in This Edition Development Environments Used in This Book Supplementary Materials for This Book Conventions Used in This Book Where to Find More Information Contacting the Authors I: Platform Overview 1 Presenting Android The Android Open Source Project (AOSP) The Open Handset Alliance Google Goes Mobile First Introducing the Open Handset Alliance Joining the Open Handset Alliance Manufacturers: Designing Android Devices Mobile Operators: Delivering the Android Experience Apps Drive Device Sales: Developing Android Applications Taking Advantage of All Android Has to Offer Android: Where We Are Now Android Platform Uniqueness Android: The Code Names Free and Open Source Familiar and Inexpensive Development Tools Reasonable Learning Curve for Developers Enabling Development of Powerful Applications Rich, Secure Application Integration No Costly Obstacles for Development A “Free Market” for Applications A Growing Platform The Android Platform Android’s Underlying Architecture Security and Permissions Exploring Android Applications Android beyond the OHA and GMS Amazon Fire OS Cyanogen OS and CyanogenMod Maker Movement and Open-Source Hardware Maintaining Awareness Summary Quiz Questions Exercises References and More Information 2 Setting Up for Development Configuring Your Development Environment Configuring Your Operating System for Device Debugging Configuring Your Android Hardware for Debugging Upgrading Android Studio Upgrading the Android SDK Problems with Android Studio Problems with the Android SDK IntelliJ IDEA as an Android Studio Alternative Exploring the Android SDK Understanding the Android SDK License Agreement Reading the Android SDK Documentation Exploring the Core Android Application Framework Exploring the Core Android Tools Exploring the Android Sample Applications Summary Quiz Questions Exercises References and More Information 3 Creating Your First Application Testing Your Development Environment Importing the BorderlessButtons Sample into Android Studio Using the Preinstalled AVD for Running Your BorderlessButtons Project Running the BorderlessButtons Application in the Android Emulator Building Your First Android Application Creating and Configuring a New Android Project Understanding the Android Symbolic View and the Traditional Project View Core Files and Directories of the Android Application Running Your Android Application in the Emulator Debugging Your Android Application in the Emulator Adding Logging Support to Your Android Application Debugging Your Application on Hardware Summary Quiz Questions Exercises References and More Information II: Application Basics 4 Understanding Application Components Mastering Important Android Terminology The Application Context Retrieving the Application Context Using the Application Context Performing Application Tasks with Activities The Lifecycle of an Android Activity Organizing Activity Components with Fragments Managing Activity Transitions with Intents Transitioning between Activities with Intents Organizing Application Navigation with Activities, Fragments, and Intents Working with Services Receiving and Broadcasting Intents Summary Quiz Questions Exercises References and More Information 5 Defining the Manifest Configuring Android Applications Using the Android Manifest File Editing the Android Manifest File Managing Your Application’s Identity Setting the Application Name and Icon Enforcing Application System Requirements Enforcing Application Platform Requirements Other Application-Configuration Settings and Filters Registering Activities in the Android Manifest Designating a Primary Entry-Point Activity for Your Application Using an Intent Filter Configuring Other Intent Filters Registering Other Application Components Working with Permissions Registering Permissions Your Application Requires Registering Permissions Your Application Enforces Exploring Other Manifest File Settings Summary Quiz Questions Exercises References and More Information 6 Managing Application Resources What Are Resources? Storing Application Resources Resource Value Types Accessing Resources Programmatically Adding Simple Resource Values in Android Studio Working with Different Types of Resources Working with String Resources Using String Resources as Format Strings Working with Quantity Strings Working with String Arrays Working with Boolean Resources Working with Integer Resources Working with Colors Working with Dimensions Using Dimension Resources Programmatically Drawable Resources Working with Images Working with Color State Lists Working with Animation Working with Menus Working with XML Files Working with Raw Files References to Resources Working with Layouts Designing Layouts in Android Studio Using Layout Resources Programmatically Referencing System Resources Summary Quiz Questions Exercises References and More Information 7 Exploring Building Blocks Introducing Android Views and Layouts The Android View The Android Controls The Android Layout Displaying Text to Users with TextView Configuring Layout and Sizing Creating Contextual Links in Text Retrieving Data from Users with Text Fields Retrieving Text Input Using EditText Controls Constraining User Input with Input Filters Helping the User with Autocompletion Giving Users Choices Using Spinner Controls Allowing Simple User Selections with Buttons and Switches Using Basic Buttons Using CheckBox and ToggleButton Controls Using RadioGroup and RadioButton Retrieving Dates, Times, and Numbers from Users with Pickers Using Indicators to Display Progress and Activity to Users Indicating Progress with ProgressBar Adding Progress Indicators to the ActionBar Indicating Activity with Activity Bars and Activity Circles Adjusting Progress with Seek Bars Other Valuable User Interface Controls Displaying Rating Data with RatingBar Showing Time Passage with the Chronometer Displaying the Time Playing Video with VideoView Summary Quiz Questions Exercises References and More Information 8 Positioning with Layouts Creating User Interfaces in Android Creating Layouts Using XML Resources Creating Layouts Programmatically Organizing Your User Interface Using ViewGroup Subclasses for Layout Design Using ViewGroup Subclasses as View Containers Using Built-in Layout Classes Using LinearLayout Using RelativeLayout Using FrameLayout Using TableLayout Using GridLayout Using Multiple Layouts on a Screen Using Container Control Classes Using Data-Driven Containers Adding Scrolling Support Exploring Other View Containers Summary Quiz Questions Exercises References and More Information 9 Partitioning with Fragments Understanding Fragments Understanding the Fragment Lifecycle Managing Fragment Modifications Working with Special Types of Fragments Designing Fragment-Based Applications Using the Android Support Library Package Adding Fragment Support to Legacy Applications Using Fragments in New Applications Targeting Older Platforms Linking the Android Support Package to Your Project Additional Ways to Use Fragments Behavior Fragments without a User Interface Exploring Nested Fragments Summary Quiz Questions Exercises References and More Information III: Application Design Essentials 10 Architecting with Patterns Architecting Your Application’s Navigation Android Application Navigation Scenarios Launching Tasks and Navigating the Back Stack Navigating with Fragments Relationships between Screens Android Navigation Design Patterns Encouraging Action Menus Action Bars Floating Action Button Actions Originating from Your Application’s Content Dialogs Summary Quiz Questions Exercises References and More Information 11 Appealing with Style Styling with Support Themes and Styles Defining the Default Application Themes Theme and Style Inheritance Colors Layout Merge and Include TextInputLayout FloatingActionButton Toolbar as Bottom Bar Application Branding The Results Applied Typography Summary Quiz Questions Exercises References and More Information 12 Embracing Material Design Understanding Material The Default Material Theme The SampleMaterial Application Implementing the SampleMaterial Application Dependencies Material Support Styles Showing the Dataset in the List Summary Quiz Questions Exercises References and More Information 13 Designing Compatible Applications Maximizing Application Compatibility Designing User Interfaces for Compatibility Working with Fragments Leveraging the Various Android Support Library APIs Supporting Specific Screen Types Working with Nine-Patch Stretchable Graphics Providing Alternative Application Resources Understanding How Resources Are Resolved Organizing Alternative Resources with Qualifiers Providing Resources for Different Orientations Using Alternative Resources Programmatically Organizing Application Resources Efficiently Targeting Tablets and TVs Targeting Tablet Devices Targeting TV Devices Extending Your Application to Watches and Cars Ensuring Compatibility with SafetyNet Summary Quiz Questions Exercises References and More Information IV: Application Development Essentials 14 Using Android Preferences Working with Application Preferences Determining When Preferences Are Appropriate Storing Different Types of Preference Values Creating Private Preferences for Use by a Single Activity Creating Shared Preferences for Use by Multiple Activities Searching and Reading Preferences Adding, Updating, and Deleting Preferences Reacting to Preference Changes Finding Preferences Data on the File System Creating Manageable User Preferences Creating a Preference Resource File Using the PreferenceActivity Class Organizing Preferences with Headers Auto Backup for Android Applications Summary Quiz Questions Exercises References and More Information 15 Accessing Files and Directories Working with Application Data on a Device Practicing Good File Management Understanding Android File Permissions Working with Files and Directories Exploring the Android Application Directories Working with Other Directories and Files on the Android File System Summary Quiz Questions Exercises References and More Information 16 Saving with SQLite SampleMaterial Upgraded with SQLite Working with Databases Providing Data Access Updating the SampleMaterialActivity Class Updating the SampleMaterialAdapter Constructor Database Operations Off the Main UI Thread Creating a Card in the Database Getting All Cards Adding a New Card Updating a Card Deleting a Card Summary Quiz Questions Exercises References and More Information 17 Leveraging Content Providers Explori...
View Full Document

  • Summer '16
  • Mobile operating system, Android Studio, Android application, Android applications

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes