Search code examples
androidandroid-cameraandroid-camera2

Flash is not supported for front camera, though stock Camera app has flash support for front camera


On Samsung S10 I can't enable flash using front camera (both camera2 and legacy camera API return false when checking support of flash for this camera)

For example

Timber.d("flashSupport ${CameraUtil.isFlashAvailable(this, "0")}, ${CameraUtil.isFlashAvailable(this, "1")}")

"0" - id of back camera "1" - id of front camera

output:

flashSupport true, false

fun isFlashAvailable(context: Context, cameraId: String): Boolean {
    val characteristics = getCameraCharacteristics(context, cameraId)
    return characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE) == true
}

So I can enable flash only for back camera but not for front camera? Why so? Samsung limits it and allows only for their system Camera app or is there something else?


Solution

  • From looking at the specs of the Samsung S10, it doesn't appear to have a front-facing flash unit?

    MAIN CAMERA: Triple 12 MP, f/1.5-2.4, 26mm (wide), 1/2.55", 1.4µm, Dual Pixel PDAF, OIS 12 MP, f/2.4, 52mm (telephoto), 1/3.6", 1.0µm, AF, OIS, 2x optical zoom 16 MP, f/2.2, 12mm (ultrawide), 1/3.1", 1.0µm, Super Steady video

    Features: LED flash, auto-HDR, panorama Video 4K@60fps (no EIS), 4K@30fps, 1080p@30/60/240fps, 720p@960fps, HDR10+, stereo sound rec., gyro-EIS & OIS

    SELFIE CAMERA: Single 10 MP, f/1.9, 26mm (wide), 1/3", 1.22µm, Dual Pixel PDAF

    Features: Dual video call, Auto-HDR Video 4K@30/60fps, 1080p@30fps

    It's possible Samsung's camera app implements a 'flash' by turning the screen white and lighting up the user that way. If so, you can implement the same thing in your own app.

    But the camera API only lists regular flash units with an LED or other strobe light.