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 ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.