Flashlight Camera2 API

后端 未结 4 1460
粉色の甜心
粉色の甜心 2020-12-11 12:01

Can I use camera preview and flashlight at the same time in Android Camera2 API?

When I try use CameraManager.setTorchMode(String cameraId, boolean enabled)

4条回答
  •  死守一世寂寞
    2020-12-11 12:28

    No, they're mutually exclusive.

    The camera device needs exclusive control of the flash while the camera is open, to ensure it can fire it as needed for pictures and so on.

    If you want to turn on the torch while the camera is open, then use the camera API's flash mode setting. For the new camera2 API, that's setting the auto-exposure mode to just ON (CONTROL_AE_MODE_ON) and the flash mode to TORCH (FLASH_MODE_TORCH). And for the old camera API, that's Parameters.setFlashMode.

提交回复
热议问题