You are previewing Programming Android, 2nd Edition.

Programming Android, 2nd Edition

Cover of Programming Android, 2nd Edition by G. Blake Meike... Published by O'Reilly Media, Inc.
  1. Programming Android
  2. Preface
    1. How This Book Is Organized
    2. Conventions Used in This Book
    3. Using Code Examples
    4. Safari® Books Online
    5. How to Contact Us
    6. Acknowledgments
  3. I. Tools and Basics
    1. 1. Installing the Android SDK and Prerequisites
      1. Installing the Android SDK and Prerequisites
      2. Test Drive: Confirm That Your Installation Works
      3. Components of the SDK
      4. Keeping Up-to-Date
      5. Example Code
      6. On Reading Code
    2. 2. Java for Android
      1. Android Is Reshaping Client-Side Java
      2. The Java Type System
      3. Scope
      4. Idioms of Java Programming
    3. 3. The Ingredients of an Android Application
      1. Traditional Programming Models Compared to Android
      2. Activities, Intents, and Tasks
      3. Other Android Components
      4. Component Life Cycles
      5. Static Application Resources and Context
      6. The Android Application Runtime Environment
      7. Extending Android
      8. Concurrency in Android
      9. Serialization
    4. 4. Getting Your Application into Users’ Hands
      1. Application Signing
      2. Placing an Application for Distribution in the Android Market
      3. Alternative Distribution
      4. Google Maps API Keys
      5. Specifying API-Level Compatibility
      6. Compatibility with Many Kinds of Screens
    5. 5. Eclipse for Android Software Development
      1. Eclipse Concepts and Terminology
      2. Eclipse Views and Perspectives
      3. Java Coding in Eclipse
      4. Eclipse and Android
      5. Preventing Bugs and Keeping Your Code Clean
      6. Eclipse Idiosyncrasies and Alternatives
  4. II. About the Android Framework
    1. 6. Building a View
      1. Android GUI Architecture
      2. Assembling a Graphical Interface
      3. Wiring Up the Controller
      4. The Menu and the Action Bar
      5. View Debugging and Optimization
    2. 7. Fragments and Multiplatform Support
      1. Creating a Fragment
      2. Fragment Life Cycle
      3. The Fragment Manager
      4. Fragment Transactions
      5. The Support Package
      6. Fragments and Layout
    3. 8. Drawing 2D and 3D Graphics
      1. Rolling Your Own Widgets
      2. Bling
    4. 9. Handling and Persisting Data
      1. Relational Database Overview
      2. SQLite
      3. The SQL Language
      4. SQL and the Database-Centric Data Model for Android Applications
      5. The Android Database Classes
      6. Database Design for Android Applications
      7. Using the Database API: MJAndroid
  5. III. A Skeleton Application for Android
    1. 10. A Framework for a Well-Behaved Application
      1. Visualizing Life Cycles
      2. Visualizing the Fragment Life Cycle
      3. The Activity Class and Well-Behaved Applications
      4. Life Cycle Methods of the Application Class
    2. 11. Building a User Interface
      1. Top-Level Design
      2. Visual Editing of User Interfaces
      3. Starting with a Blank Slate
      4. Laying Out the Fragments
      5. Folding and Unfolding a Scalable UI
      6. Making Activity, Fragment, Action Bar, and Multiple Layouts Work Together
      7. The Other Activity
    3. 12. Using Content Providers
      1. Understanding Content Providers
      2. Defining a Provider Public API
      3. Writing and Integrating a Content Provider
      4. File Management and Binary Data
      5. Android MVC and Content Observation
      6. A Complete Content Provider: The SimpleFinchVideoContentProvider Code
      7. Declaring Your Content Provider
    4. 13. A Content Provider as a Facade for a RESTful Web Service
      1. Developing RESTful Android Applications
      2. A “Network MVC”
      3. Summary of Benefits
      4. Code Example: Dynamically Listing and Caching YouTube Video Content
      5. Structure of the Source Code for the Finch YouTube Video Example
      6. Stepping Through the Search Application
      7. Step 1: Our UI Collects User Input
      8. Step 2: Our Controller Listens for Events
      9. Step 3: The Controller Queries the Content Provider with a managedQuery on the Content Provider/Model
      10. Step 4: Implementing the RESTful Request
  6. IV. Advanced Topics
    1. 14. Search
      1. Search Interface
      2. Query Suggestions
    2. 15. Location and Mapping
      1. Location-Based Services
      2. Mapping
      3. The Google Maps Activity
      4. The MapView and MapActivity
      5. Working with MapViews
      6. MapView and MyLocationOverlay Initialization
      7. Pausing and Resuming a MapActivity
      8. Controlling the Map with Menu Buttons
      9. Controlling the Map with the Keypad
      10. Location Without Maps
      11. StreetView
    3. 16. Multimedia
      1. Audio and Video
      2. Playing Audio and Video
      3. Recording Audio and Video
      4. Stored Media Content
    4. 17. Sensors, NFC, Speech, Gestures, and Accessibility
      1. Sensors
      2. Near Field Communication (NFC)
      3. Gesture Input
      4. Accessibility
    5. 18. Communication, Identity, Sync, and Social Media
      1. Account Contacts
      2. Authentication and Synchronization
      3. Bluetooth
    6. 19. The Android Native Development Kit (NDK)
      1. Native Methods and JNI Calls
      2. The Android NDK
      3. Native Libraries and Headers Provided by the NDK
      4. Building Your Own Custom Library Modules
      5. Native Activities
  7. Index
  8. About the Authors
  9. Colophon
  10. Copyright
O'Reilly logo

Chapter 16. Multimedia

In today’s world of converging technologies, the mobile phone is used for a variety of tasks beyond simple voice calls. Multimedia capabilities, or the playing and recording of audio and video, is one such significant task that many users find to be of great value. Take a quick look around and you will find people using the phone as a means to enjoy a variety of programs as well as share self-recorded media among friends. Android provides the APIs to easily access this capability as well as embed multimedia and its manipulation directly within an application.

Audio and Video

Android supports playback of most popular audio and video formats. It also lets you record some formats. Recordings are stored in files, and can optionally be put in a persistent media store. The MediaStore is the content provider within Android that enables the storing and sharing of media data such as images, video, and audio. Once placed within this content provider, metadata associated with the media files becomes available for other applications to use.

As of this writing, most Android devices currently on the market support the following audio and video formats. Note that device makers can add support for other formats not listed here.

Audio
AAC LC/LTP *
HE-AACv1 (AAC+)
HE-AACv2 (enhanced AAC+)
AMR-NB *
AMR-WB *
MP3
FLAC (Android 3.1+)
MIDI
Ogg Vorbis
PCM/WAVE
Video
H.263 *
H.264 AVC * (encode Android 3.0+)
MPEG-4 SP
VP8 (Android 2.3.3+)

The asterisk (*) indicates the formats for which encoding is available. ...

The best content for your career. Discover unlimited learning on demand for around $1/day.