O'Reilly logo

Xamarin Blueprints by Michael Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integrating the Android Camera2 framework

The new Camera2 framework was introduced in API 21 (5.0 Lollipop) and provides a wide featured framework for controlling camera devices connected to any Android device.

Start by setting up the folder structure Renderers | CameraView inside the Camera.Droid project. Inside the CameraView folder, add a file called CameraCaptureListener.cs and implement the following:

public class CameraCaptureListener : CameraCaptureSession.CaptureCallback 
    { 
        public event EventHandler PhotoComplete; 
 
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request,  
                    TotalCaptureResult result) 
        { 
            PhotoComplete?.Invoke(this, EventArgs.Empty); 
        } 
    } 

All we need to do is fire an event every time the OnCaptureCompleted ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required