Introduction

The camera focus function is used in video calls to enable high-quality video capture.

The Agora SDK provides a set of camera management methods on Android, with which users can switch between the front and rear cameras, set the camera zoom factor, and set the camera focus position.

Implementation

Ensure that you prepared the development environment. See Integrate the SDK.

// java
// Check whether auto-face focus is supported and enable auto-face focus.
boolean shouldSetFaceMode = rtcEngine.isCameraAutoFocusFaceModeSupported();
rtcEngine.setCameraAutoFocusFaceModeEnabled(shouldSetFaceMode);

// Check whether manual focus is supported and set the focus.
boolean shouldManualFocus = rtcEngine.isCameraFocusSupported();
if (shouldManualFocus) {
    // Set the camera focus at (50, 100).
    float positionX = 50.0f;
    float positionY = 100.0f;
    rtcEgnine.setCameraFocusPositionInPreview(positionX, positionY);
}

API Methods