You are previewing Android™ Development Patterns: Best Practices for Professional Developers.
O'Reilly logo
Android™ Development Patterns: Best Practices for Professional Developers

Book Description

“A must read for all developers that want to begin serious Android development.”
Justin Anderson, Freelance Android Developer

“From start to finish, this book contains a variety of great tips and insight into the most important attributes of Android design. This book will definitely be required reading for any of our future Android engineers.”
Cameron Banga, Cofounder, 9magnets, LLC

There’s a downside to Android’s amazing openness and versatility: it’s easy for developers to write code that’s inefficient, unreliable, insecure, or hard to maintain. In Android Development Patterns, enterprise Android developer Phil Dutson helps you leverage Android 5.0+’s amazing power without falling victim to those pitfalls. Dutson presents today’s most comprehensive set of patterns and procedures for building optimized, robust apps with Android 5.0+.

First, Dutson guides you through establishing a highly efficient development environment and workflow, and testing your app to ensure that your code works just as you expect. Then, he walks through the modern best practices for structuring apps, using widgets and components, and working with views.

You learn how to build apps that are easy to manage and update, deliver accurate and up-to-date information without wasting precious battery power, and take advantage of new hardware, such as Android Wear and Android TV. Dutson concludes by presenting powerful strategies for optimizing your apps and packaging them for distribution.

Coverage includes

  • Using testing to build more trustworthy, dependable, maintainable apps

  • Understanding subtle but critical differences between Android and traditional Java programming

  • Building consistent, modern user interfaces with views and layouts

  • Leveraging the proven MVC pattern to cleanly organize logic

  • Creating rich visual experiences with 3D graphics, animation, and media

  • Simplifying capture and use of location data with the new Locations API

  • Integrating optional hardware, such as Bluetooth, NFC, or USB

  • Building better apps with Google Play Services

  • Creating Android Wear notifications and apps

  • Tuning and improving apps with Google Analytics

  • Designing Android TV apps for the “ten foot view”

  • informit.com/aw | https://github.com/dutsonpa/adp-files

    Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents
    6. Preface
      1. Why Development Patterns?
      2. Who Should Read This Book?
      3. Getting Started
      4. Book Structure
    7. Acknowledgments
    8. About the Author
    9. 1. Development Tools
      1. Android Studio
        1. Installing Android Studio
        2. Using Android Studio
        3. Starting a New Project
      2. Standalone SDK Tools
      3. Android Device Emulation
        1. Android Virtual Device
        2. GenyMotion
        3. Xamarin Android Player
      4. Version-Control Systems
        1. Subversion
        2. Git
        3. Mercurial
      5. Summary
    10. 2. Testing and Debugging
      1. Unit Testing
      2. Integration Testing
      3. Debugging
        1. Profiling
        2. Tracing
        3. Messaging
      4. Summary
    11. 3. Application Structure
      1. Manifests
      2. Java
      3. Res (Resources)
        1. Drawable
        2. Layout
        3. Menu
        4. Values
        5. Other Resources
      4. Gradle
      5. Summary
    12. 4. Components
      1. Intents
        1. Intent Filters
        2. Broadcast Receivers
      2. Activities
        1. Creating an Activity
        2. Activity Lifecycle
      3. Fragments
        1. Creating a Fragment
        2. Communicating with Fragments
        3. Loaders
      4. Summary
    13. 5. Views
      1. The View Class
        1. The AnalogClock Subclass
        2. The ImageView Subclass
        3. The KeyboardView Subclass
        4. The MediaRouteButton Subclass
        5. The ProgressBar Subclass
        6. The Space Subclass
        7. The SurfaceView Subclass
        8. The TextView Subclass
        9. The TextureView Subclass
        10. The ViewGroup Subclass
        11. The ViewStub Subclass
      2. Creating a Custom View
      3. Summary
    14. 6. Layout
      1. Layout Basics
        1. Layout Measurements
        2. Layout Coordinates
      2. Layout Containers
        1. Linear Layout
        2. Relative Layout
        3. Table Layout
        4. Frame Layout
        5. WebView
      3. Summary
    15. 7. App Widgets
      1. App Widget Layouts
      2. The AppWidgetProviderInfo Object
        1. App Widget Sizing
        2. Update Frequency
        3. Preview Image
        4. Widget Category
        5. Widget Category Layout
        6. Resizable Mode
        7. Sample AppWidgetProviderInfo Object
      3. The AppWidgetProvider Class
      4. Application Manifest Entries
      5. Summary
    16. 8. Application Design: Using MVC
      1. Model
      2. View
      3. Controller
      4. Working Asynchronously
        1. AsyncTask
      5. Summary
    17. 9. Drawing and Animation
      1. Graphics
        1. Bitmaps
        2. NinePatch
        3. Drawables
        4. OpenGL ES
      2. Animation
        1. View Animation
        2. Property Animation
        3. Drawable Animation
        4. Transition Framework
      3. Summary
    18. 10. Networking
      1. Accessing the Internet
        1. Network Detection
        2. Using an HTTP Client
      2. Parsing XML
      3. Handling Network Operations Asynchronously
      4. Volley
      5. Summary
    19. 11. Working with Location Data
      1. Permissions
      2. Google Play Services Locations API
      3. Summary
    20. 12. Multimedia
      1. Working with Audio
        1. Audio Playback
        2. Audio Recording
      2. Working with Video
        1. Video Playback
      3. Summary
    21. 13. Optional Hardware APIs
      1. Bluetooth
        1. Enabling Bluetooth
        2. Discovering Devices with Bluetooth
        3. Connecting via Bluetooth Classic
        4. Communicating with BLE
      2. Near Field Communication
        1. ACTION_NDEF_DISCOVERED
        2. ACTION_TECH_DISCOVERED
        3. ACTION_TAG_DISCOVERED
      3. Device Sensors
        1. Detecting the Available Sensors
        2. Reading Sensor Data
      4. Summary
    22. 14. Managing Account Data
      1. Getting Accounts
      2. Android Backup Service
      3. Using Google Drive Android API
      4. Using Google Play Games Services
        1. Working with Saved Games
      5. Summary
    23. 15. Google Play Services
      1. Adding Google Play Services
      2. Using Google API Client
      3. Google Fit
        1. Enable API and Authentication
        2. App Configuration and Connection
      4. Nearby Messages API
        1. Enabling Nearby Messages
        2. Sending and Receiving Messages
      5. Summary
    24. 16. Android Wear
      1. Android Wear Basics
      2. Screen Considerations
      3. Debugging
        1. Connecting to an Emulator
        2. Connecting to a Wear Device
      4. Communicating with Android Wear
        1. Notifications
        2. Sending Data
      5. Summary
    25. 17. Google Analytics
      1. Adding Google Analytics
      2. Google Analytics Basics
        1. Events
        2. Goals
        3. Ecommerce
        4. Custom Timings
        5. Custom Dimensions
        6. Custom Metrics
      3. Summary
    26. 18. Optimization
      1. Application Optimization
        1. Application First
        2. Application Logging
        3. Application Configuration
      2. Memory Management
        1. Garbage Collection Monitoring
        2. Checking Memory Usage
      3. Performance
        1. Working with Objects
        2. Static Methods and Variables
        3. Enhanced for Loops
        4. float, double, and int
        5. Optimized Data Containers
      4. Summary
    27. 19. Android TV
      1. The Big Picture
        1. Ten-Foot View
        2. TV Capabilities
        3. Text, Color, and Bitmaps
      2. Building an App
      3. Emulation and Testing
      4. Summary
    28. 20. Application Deployment
      1. Preparing for Deployment
      2. Production Checklist
        1. Certificate Keys
        2. Contact Email
        3. App Website
        4. External Services or Servers
        5. Application Icon
        6. Licensing
        7. Appropriate Package Name
        8. Verifying Permissions and Requirements
        9. Log and Debug Removal
        10. Removal of Excess Unused Assets
      3. Preparing for Google Play
        1. Application Screenshots
        2. Promo Video
        3. High-Res Icon
        4. Feature Graphic
        5. Promo Graphic
        6. Banner for Android TV
        7. Getting Paid
      4. APK Generation
      5. Summary
    29. Index
    30. Code Snippets