Android Recipes: A Problem-Solution Approach for Android 5.0, Fourth Edition

Book description

Android Recipes, Fourth Edition offers more than 100 down-to-earth code recipes, and guides you step-by-step through a wide range of useful topics using complete and real-world working code examples. This book is updated to include the Android 5.0 SDK, as well as earlier releases.

Instead of abstract descriptions of complex concepts, in Android Recipes, you'll find live code examples. When you start a new project you can consider copying and pasting the code and configuration files from this book and then modifying them for your own customization needs.

Crammed with insightful instruction and helpful examples, this fourth edition of Android Recipes is your guide to writing apps for one of today’s hottest mobile platforms. It offers pragmatic advice that will help you get the job done quickly and well. This can save you a great deal of work over creating a project from scratch!

Android continues to be one of the leading mobile OS and development platforms driving today's mobile innovations and the apps ecosystem. Android appears complex, but offers a variety of organized development kits to those coming into Android with differing programming language skill sets.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Contents at a Glance
  5. Contents
  6. About the Author
  7. About the Technical Reviewer
  8. Acknowledgments
  9. Introduction
  10. Chapter 1: Layouts and Views
    1. 1-1. Styling Common Components
      1. Problem
      2. Solution
      3. How It Works
    2. 1-2. Toggling System UI Elements
      1. Problem
      2. Solution
      3. How It Works
    3. 1-3. Creating and Displaying Views
      1. Problem
      2. Solution
      3. How It Works
    4. 1-4. Animating a View
      1. Problem
      2. Solution
      3. How It Works
    5. 1-5. Animating Layout Changes
      1. Problem
      2. Solution
      3. How It Works
    6. 1-6. Implementing Situation-Specific Layouts
      1. Problem
      2. Solution
      3. How It Works
    7. 1-7. Customizing AdapterView Empty Views
      1. Problem
      2. Solution
      3. How It Works
    8. 1-8. Customizing ListView Rows
      1. Problem
      2. Solution
      3. How It Works
    9. 1-9. Making ListView Section Headers
      1. Problem
      2. Solution
      3. How It Works
    10. 1-10. Creating Compound Controls
      1. Problem
      2. Solution
      3. How It Works
    11. 1-11. Customizing Transition Animations
      1. Problem
      2. Solution
      3. How It Works
    12. 1-12. Creating View Transformations
      1. Problem
      2. Solution
      3. How It Works
    13. 1-13. Making Extensible Collection Views
      1. Problem
      2. Solution
      3. How It Works
    14. Summary
  11. Chapter 2: User Interaction Recipes
    1. 2-1. Leveraging the Action Bar
      1. Problem
      2. Solution
      3. How It Works
    2. 2-2. Locking Activity Orientation
      1. Problem
      2. Solution
      3. How It Works
    3. 2-3. Performing Dynamic Orientation Locking
      1. Problem
      2. Solution
      3. How It Works
    4. 2-4. Manually Handling Rotation
      1. Problem
      2. Solution
      3. How It Works
    5. 2-5. Creating Contextual Actions
      1. Problem
      2. Solution
      3. How It Works
    6. 2-6. Displaying a User Dialog Box
      1. Problem
      2. Solution
      3. How It Works
    7. 2-7. Customizing Menus and Actions
      1. Problem
      2. Solution
      3. How It Works
    8. 2-8. Customizing BACK Behavior
      1. Problem
      2. Solution
      3. How It Works
    9. 2-9. Emulating the HOME Button
      1. Problem
      2. Solution
      3. How It Works
    10. 2-10. Monitoring TextView Changes
      1. Problem
      2. Solution
      3. How It Works
    11. 2-11. Customizing Keyboard Actions
      1. Problem
      2. Solution
      3. How It Works
    12. 2-12. Dismissing the Soft Keyboard
      1. Problem
      2. Solution
      3. How It Works
    13. 2-13. Handling Complex Touch Events
      1. Problem
      2. Solution
      3. How It Works
    14. 2-14. Forwarding Touch Events
      1. Problem
      2. Solution
      3. How It Works
    15. 2-15. Blocking Touch Thieves
      1. Problem
      2. Solution
      3. How It Works
    16. 2-16. Making Drag-and-Drop Views
      1. Problem
      2. Solution
      3. How It Works
    17. 2-17. Building a Navigation Drawer
      1. Problem
      2. Solution
      3. How It Works
    18. 2-18. Swiping Between Views
      1. Problem
      2. Solution
      3. How It Works
    19. 2-19. Navigating with Tabs
      1. Problem
      2. Solution
      3. How It Works
    20. Summary
  12. Chapter 3: Communications and Networking
    1. 3-1. Displaying Web Information
      1. Problem
      2. Solution
      3. How It Works
    2. 3-2. Intercepting WebView Events
      1. Problem
      2. Solution
      3. How It Works
    3. 3-3. Accessing WebView with JavaScript
      1. Problem
      2. Solution
      3. How It Works
    4. 3-4. Downloading an Image File
      1. Problem
      2. Solution
      3. How It Works
    5. 3-5. Downloading Completely in the Background
      1. Problem
      2. Solution
      3. How It Works
    6. 3-6. Accessing a REST API
      1. Problem
      2. Solution
      3. How It Works
    7. 3-7. Parsing JSON
      1. Problem
      2. Solution
      3. How It Works
    8. 3-8. Parsing XML
      1. Problem
      2. Solution
      3. How It Works
    9. 3-9. Receiving SMS
      1. Problem
      2. Solution
      3. How It Works
    10. 3-10. Sending an SMS Message
      1. Problem
      2. Solution
      3. How It Works
    11. 3-11. Communicating over Bluetooth
      1. Problem
      2. Solution
      3. How It Works
    12. 3-12. Querying Network Reachability
      1. Problem
      2. Solution
      3. How It Works
    13. 3-13. Transferring Data with NFC
      1. Problem
      2. Solution
      3. How It Works
    14. 3-14. Connecting over USB
      1. Problem
      2. Solution
      3. How It Works
    15. Summary
  13. Chapter 4: Interacting with Device Hardware and Media
    1. 4-1. Integrating DeviceLocation
      1. Problem
      2. Solution
      3. How It Works
    2. 4-2. Mapping Locations
      1. Problem
      2. Solution
      3. How It Works
    3. 4-3. Annotating Maps
      1. Problem
      2. Solution
      3. How It Works
    4. 4-4. Monitoring Location Regions
      1. Problem
      2. Solution
      3. How It Works
    5. 4-5. Capturing Images and Video
      1. Problem
      2. Solution
      3. How It Works
    6. 4-6. Making a Custom Camera Overlay
      1. Problem
      2. Solution
      3. How It Works
    7. 4-7. Recording Audio
      1. Problem
      2. Solution
      3. How It Works
    8. 4-8. Capturing Custom Video
      1. Problems
      2. Solution
      3. How It Works
    9. 4-9. Adding Speech Recognition
      1. Problem
      2. Solution
      3. How It Works
    10. 4-10. Playing Back Audio/Video
      1. Problem
      2. Solution
      3. How It Works
    11. 4-11. Playing Sound Effects
      1. Problem
      2. Solution
      3. How It Works
    12. 4-12. Creating a Tilt Monitor
      1. Problem
      2. Solution
      3. How It Works
    13. 4-13. Monitoring Compass Orientation
      1. Problem
      2. Solution
      3. How It Works
    14. 4-14. Retrieving Metadata from Media Content
      1. Problem
      2. Solution
      3. How It Works
    15. 4-15. Detecting User Motion
      1. Problem
      2. Solution
      3. How It Works
    16. Summary
  14. Chapter 5: Persisting Data
    1. 5-1. Making a Preference Screen
      1. Problem
      2. Solution
      3. How It Works
    2. 5-2. Displaying Custom Preferences
      1. Problem
      2. Solution
      3. How It Works
    3. 5-3. Persisting Simple Data
      1. Problem
      2. Solution
      3. How It Works
    4. 5-4. Reading and Writing Files
      1. Problem
      2. Solution
      3. How It Works
    5. 5-5. Using Files as Resources
      1. Problem
      2. Solution
      3. How It Works
    6. 5-6. Managing a Database
      1. Problem
      2. Solution
      3. How It Works
    7. 5-7. Querying a Database
      1. Problem
      2. Solution
      3. How It Works
    8. 5-8. Backing Up Data
      1. Problem
      2. Solution
      3. How It Works
    9. 5-9. Sharing Your Database
      1. Problem
      2. Solution
      3. How It Works
    10. 5-10. Sharing Your SharedPreferences
      1. Problem
      2. Solution
      3. How It Works
    11. 5-11. Sharing Your Other Data
      1. Problem
      2. Solution
      3. How It Works
    12. 5-12. Integrating with System Documents
      1. Problem
      2. Solution
      3. How It Works
    13. Summary
  15. Chapter 6: Interacting with the System
    1. 6-1. Notifying from the Background
      1. Problem
      2. Solution
      3. How It Works
    2. 6-2. Creating Timed and Periodic Tasks
      1. Problem
      2. Solution
      3. How It Works
    3. 6-3. Scheduling a Periodic Task
      1. Problem
      2. Solution
      3. How It Works
    4. 6-4. Creating Sticky Operations
      1. Problem
      2. Solution
      3. How It Works
    5. 6-5. Running Persistent Background Operations
      1. Problem
      2. Solution
      3. How It Works
    6. 6-6. Launching Other Applications
      1. Problem
      2. Solution
      3. How It Works
    7. 6-7. Launching System Applications
      1. Problem
      2. Solution
      3. How It Works
    8. 6-8. Letting Other Applications Launch Your Application
      1. Problem
      2. Solution
      3. How It Works
    9. 6-9. Interacting with Contacts
      1. Problem
      2. Solution
      3. How It Works
    10. 6-10. Reading Device Media and Documents
      1. Problem
      2. Solution
      3. How It Works
    11. 6-11. Saving Device Media and Documents
      1. Problem
      2. Solution
      3. How It Works
    12. 6-12. Reading Messaging Data
      1. Problem
      2. Solution
      3. How It Works
    13. 6-13. Interacting with the Calendar
      1. Problem
      2. Solution
      3. How It Works
    14. 6-14. Logging Code Execution
      1. Problem
      2. Solution
      3. How It Works
    15. 6-15. Creating a Background Worker
      1. Problem
      2. Solution
      3. How It Works
    16. 6-16. Customizing the Task Stack
      1. Problem
      2. Solution
      3. How It Works
    17. 6-17. Implementing AppWidgets
      1. Problem
      2. Solution
      3. How It Works
    18. 6-18. Supporting Restricted Profiles
      1. Problem
      2. Solution
      3. How It Works
    19. Summary
  16. Chapter 7: Graphics and Drawing
    1. 7-1. Creating Drawables as Backgrounds
      1. Problem
      2. Solution
      3. How It Works
    2. 7-2. Creating Custom State Drawables
      1. Problem
      2. Solution
      3. How It Works
    3. 7-3. Applying Masks to Images
      1. Problem
      2. Solution
      3. How It Works
    4. 7-4. Drawing Over View Content
      1. Problem
      2. Solution
      3. How It Works
    5. 7-5. High-Performance Drawing
      1. Problem
      2. Solution
      3. How It Works
    6. 7-6. Extracting Image Color Palettes
      1. Problem
      2. Solution
      3. How It Works
    7. 7-7. Tinting Drawable Elements
      1. Problem
      2. Solution
      3. How It Works
    8. 7-8. Using Scalable Vector Assets
      1. Problem
      2. Solution
      3. How It Works
    9. Summary
  17. Chapter 8: Working with Android NDK and RenderScript
    1. Android NDK
    2. 8-1. Adding Native Bits with JNI
      1. Problem
      2. Solution
      3. How It Works
    3. 8-2. Building a Purely Native Activity
      1. Problem
      2. Solution
      3. How It Works
    4. RenderScript
      1. Using the RenderScript Support Package
    5. 8-3. Filtering Images with RenderScript
      1. Problem
      2. Solution
      3. How It Works
    6. 8-4. Manipulating Images with RenderScript
      1. Problem
      2. Solution
      3. How It Works
    7. 8-5. Faking Translucent Overlays with Blur
      1. Problem
      2. Solution
      3. How It Works
    8. Summary
  18. Index

Product information

  • Title: Android Recipes: A Problem-Solution Approach for Android 5.0, Fourth Edition
  • Author(s): Dave Smith
  • Release date: February 2015
  • Publisher(s): Apress
  • ISBN: 9781484204757