Android Camera & Media samples

A selection of code samples for you to use to accelerate your app development. Browse samples to learn how to build different components for your apps.

Media code samples

SociaLite

This sample shows how to use various Android platform APIs and Jetpack libraries to implement features that are commonly seen in social network apps.

Platform samples

This repository contains a collection of samples that demonstrate the use of different Android OS platform APIs, including camera and media APIs.

Media3 Transformer

This sample shows how to use the Media3 Transformer APIs to create a media editing app.

Camera code samples

CameraX Basic

How to use CameraX APIs written in Kotlin.

CameraX Video

How to use the CameraX Video Capture (Recorder) API with Capture + Preview for the MediaStore format.

CameraX Advanced

How to perform real-time object detection on the live camera frames with TensorFlow Lite.

CameraX-MLKit

How to use CameraX's MlKitAnalyzer to perform QR Code scanning. For QR Codes that encode URLs, this app prompts the user to open the URL in a browser.

CameraX Extensions

How to use Camera Extensions with CameraX API to capture a JPEG, display the camera preview, query for supported extensions, select an extension, and capture a still image. Available extensions include Auto, Bokeh, Face Retouch, HDR (High Dynamic Range), and Night.

HDR Viewfinder (Camera2)

How to implement a real-time high-dynamic-range camera viewfinder, by alternating the sensor's exposure time between two exposure values on even and odd frames, and then compositing together the latest two frames whenever a new frame is captured

Test & validation

Media Controller Test app

A sample implementation of the MediaController API that you can use to test the intricacies of media playback on Android and to verify your media session implementation.

API Demos

Media3 Main Demo

A simple playback app that uses ExoPlayer to play a number of test streams. A good starting point or reference project.

Media3 Session Demo

A playback app that implements a MediaSession.

Media3 Cast Demo

A playback app with Google Cast integration. Demonstrates switching between Cast playback and local playback.

Media3 SurfaceControl Demo

A playback app that uses the SurfaceControl API to redirect ExoPlayer’s video output to different views. Requires minSdkVersion 29.

Media3 GL Demo

A playback app that renders video to a GLSurfaceView and applies a GL shader.

MIDI Samples

This collection of sample apps showcases MIDI 2.0 APIs introduced in Android 13.