Camera exposure and focus are commonly used functions in video calls to enable high quality video capture.

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

Camera exposure: Auto exposure is supported where users can maually set the exposure region.
Camera focus: Auto face-focus and manual focus are supported.


Before proceeding, ensure that you have finished preparing the development environment. See Integrate the SDK for details.

// java
// Check whether exposure function is supported and enable exposure
boolean shouldSetExposure = rtcEngine.isCameraExposurePositionSupported();
if (shouldSetExposure) {
    // Set the camera exposure at (50, 100)
    float positionX = 50.0f;
    float positionY = 100.0f;
    rtcEngine.setCameraExposurePosition(positionX, positionY);
// Check whether auto face-focus function is supported and enable auto-face focus
boolean shouldSetFaceMode = rtcEngine.isCameraAutoFocusFaceModeSupported();

// Check whether manual focus function 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;
    rtcEngine.setCameraFocusPositionInPreview(positionX, positionY);

You can also get the focus and exposure area in the onCameraFocusAreaChanged and onCameraExposureAreaChanged callbacks.

// java
public void onCameraFocusAreaChanged(rect) {
// The camera focus area is updated
// You can monitor the update event and implement corresponding logic

public void onCameraExposureAreaChanged(rect) {
// The camera exposure area is updated
// You can monitor the update event the implement corresponding logic

API Reference