Android Recipes: A Problem-Solution Approach, Second Edition

Book description

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.

Android Recipes: A Problem-Solution Approach, Second Edition guides you step-by-step through a wide range of useful topics using complete and real-world working code examples. It's updated to include latest Jelly Bean Android SDK as well as earlier releases.

In this expanded edition,

  • You'll start off with a recap of Android architecture and app fundamentals, and then get down to business and build an app with Android SDK 4.1 version or earlier release at the command line and Eclipse.

  • Next, you'll learn how to accomplish practical tasks pertaining to the user interface, communications with the cloud, device hardware, data persistence, communications between applications, and interacting with Android itself.

  • Finally, you'll learn how to leverage various libraries and Scripting Layer for Android (SL4A) to help you perform tasks more quickly, how to use the Android NDK to boost app performance, and how to design apps for performance, responsiveness, seamlessness, and more.

  • 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, then modifying them for your own customization needs. This can save you a great deal of work over creating a project from scratch!

    What you'll learn

  • Discover Android architecture and various Android-specific APIs

  • How to develop a unit conversion app in the context of command-line/Android SDK and Eclipse/Android SDK environments

  • How to accomplish various tasks related to the user interface and more

  • How to use external libraries to save time and effort

  • How to quickly develop an app using the Scripting Layer for Android (SL4A) tool

  • How to boost app performance by using the Android NDK

  • Guidelines for designing filtered apps, performant apps, responsive apps, and seamless apps

  • Who this book is for

    This book is a handy reference for all Android app developers. Newcomers may also find this of interest, too.

    Table of contents

    1. Titlepage
    2. Contents at a Glance
    3. Contents
    4. Foreword
    5. About the Authors
    6. About the Technical Reviewer
    7. Acknowledgments
    8. Preface
    9. Chapter 1: Getting Started with Android
      1. What Is Android?
      2. History of Android
      3. Android Architecture
      4. App Architecture
      5. Summary
    10. Chapter 2: User Interface Recipes
      1. 2-1. Customizing the Window
      2. 2-2. Creating and Displaying Views
      3. 2-3. Monitoring Click Actions
      4. 2-4. Resolution-Independent Assets
      5. 2-5. Locking Activity Orientation
      6. 2-6. Dynamic Orientation Locking
      7. 2-7. Manually Handling Rotation
      8. 2-8. Creating Pop-Up Menu Actions
      9. 2-9. Displaying A User Dialog
      10. 2-10. Customizing Options Menu
      11. 2-11. Customizing Back Behavior
      12. 2-12. Emulating the HOME Button
      13. 2-13. Monitoring TextView Changes
      14. 2-14. Scrolling TextView Ticker
      15. 2-15. Animating a View
      16. 2-16. Animating Layout Changes
      17. 2-17. Creating Drawables as Backgrounds
      18. 2-18. Creating Custom State Drawables
      19. 2-19. Applying Masks to Images
      20. 2-20. Creating Dialogs That Persist
      21. 2-21. Implementing Situation-Specific Layouts
      22. 2-22. Customizing Keyboard Actions
      23. 2-23. Dismissing Soft Keyboard
      24. 2-24. Customizing AdapterView Empty Views
      25. 2-25. Customizing ListView Rows
      26. 2-26. Making ListView Section Headers
      27. 2-27. Creating Compound Controls
      28. 2–28. Handling Complex Touch Events
      29. 2-29. Forwarding Touch Events
      30. 2-30. Making Drag-and-Drop Views
      31. 2-31. Customizing Transition Animations
      32. 2-32. Creating View Transformations
      33. 2-33. Swiping Between Views
      34. 2-34. Creating Modular Interfaces
      35. 2-35. High-Performance Drawing
      36. Useful Tools to Know: Hierarchy Viewer and Lint
      37. Hierarchy Viewer
      38. Exploring the View Hierarchy Window
      39. Working with an Individual View in Tree View
      40. Debugging with View Hierarchy
      41. Exploring the Pixel Perfect Window
      42. Working with Pixel Perfect Overlays
      43. Lint
      44. Running Lint
      45. Summary
    11. Chapter 3: Communications and Networking
      1. 3–1. Displaying Web Information
      2. 3–2. Intercepting WebView Events
      3. 3–3. Accessing WebView with JavaScript
      4. 3–4. Downloading an Image File
      5. 3–5. Downloading Completely in the Background
      6. 3–6. Accessing a REST API
      7. 3–7. Parsing JSON
      8. 3–8. Parsing XML
      9. 3–9. Receiving SMS
      10. 3–10. Sending an SMS Message
      11. 3–11. Communicating over Bluetooth
      12. 3–12. Querying Network Reachability
      13. 3-13. Transferring Data with NFC
      14. 3-14. Connecting over USB
      15. Summary
    12. Chapter 4: Interacting with Device Hardware and Media
      1. 4-1. Integrating Device Location
      2. 4-2. Mapping Locations
      3. 4-3. Annotating Maps
      4. 4-4. Capturing Images and Video
      5. 4-5. Making a Custom Camera Overlay
      6. 4-6. Recording Audio
      7. 4-7. Custom Video Capture
      8. 4-8. Adding Speech Recognition
      9. 4-9. Playing Back Audio/Video
      10. 4-10. Playing Sound Effects
      11. 4-11. Creating a Tilt Monitor
      12. 4-12. Monitoring Compass Orientation
      13. 4-13. Retrieving Metadata from Media Content
      14. Useful Tools to Know: Sensor Simulator
      15. Obtaining Sensor Simulator
      16. Launching Sensor Simulator Settings and Sensor Simulator
      17. Accessing Sensor Simulator from Your Apps
      18. Summary
    13. Chapter 5: Persisting Data
      1. 5–1. Making a Preference Screen
      2. 5–2. Persisting Simple Data
      3. 5–3. Reading and Writing Files
      4. 5–4. Using Files as Resources
      5. 5–5. Managing a Database
      6. 5–6. Querying a Database
      7. 5–7. Backing Up Data
      8. 5–8. Sharing Your Database
      9. 5–9. Sharing Your SharedPreferences
      10. 5–10. Sharing Your Other Data
      11. Useful Tools to Know: SQLite3
      12. Univerter and SQLite3
      13. Summary
    14. Chapter 6: Interacting with the System
      1. 6–1. Notifying from the Background
      2. 6–2. Creating Timed and Periodic Tasks
      3. 6–3. Scheduling a Periodic Task
      4. 6–4. Creating Sticky Operations
      5. 6–5. Running Persistent Background Operations
      6. 6–6. Launching Other Applications
      7. 6–7. Launching System Applications
      8. 6–8. Letting Other Applications Launch Your Application
      9. 6–9. Interacting with Contacts
      10. 6–10. Picking Device Media
      11. 6–11. Saving to the MediaStore
      12. 6-12. Interacting with the Calendar
      13. 6-13. Logging Code Execution
      14. 6-14. Creating a Background Worker
      15. 6-15. Customizing the Task Stack
      16. 6-16. Implementing AppWidgets
      17. Summary
    15. Chapter 7: Working with Libraries
      1. 7-1. Creating Java Library JARs
      2. 7-2. Using Java Library JARs
      3. 7-3. Creating Android Library Projects
      4. 7-4. Using Android Library Projects
      5. 7-5. Charting
      6. 7-6. Practical Push Messaging
      7. 7-7. Using Google’s Support Package
      8. Summary
    16. Chapter 8: Working with Android NDK and Renderscript
      1. Android NDK
      2. 8-1. Discovering Native Activities
      3. 8-2. Developing Low-Level Native Activities
      4. 8-3. Developing High-Level Native Activities
      5. Renderscript
      6. 8-4. Learning More About Renderscript
      7. Summary
    17. Appendix A: Scripting Layer for Android
      1. Installing SL4A
      2. Exploring SL4A
      3. Installing the Python Interpreter
      4. Scripting with Python
    18. Appendix B: Android Tools Overview
      1. SDK Tools
      2. Platform Tools
    19. Appendix C: App Design Guidelines
    20. Appendix D: Univerter Architecture
      1. Exploring the Source Code
      2. Exploring the Resource Files
      3. Exploring the Manifest
    21. Index

    Product information

    • Title: Android Recipes: A Problem-Solution Approach, Second Edition
    • Author(s): Dave Smith, Jeff Friesen
    • Release date: December 2012
    • Publisher(s): Apress
    • ISBN: 9781430246145