Search code examples
androidcameraandroid-cameracamera-flash

Camera.Parameters.FLASH_MODE_ON is not working on Moto X


I m testing my app on moto x and even after setting flash mode on, flash is not working. App is working fine in other devices but not on Moto X. here is a code snippet

    cameraInstance = getCameraInstance(cameraId);

    // Setting the right parameters in the camera
    Camera.Parameters params = cameraInstance.getParameters();
    List<Size> list = params.getSupportedPictureSizes();

    Size s = list.get(0);
    for (Size size : list)
    {
        if (s.height < size.height)
            s = size;
    }

    params.setPictureSize(s.width, s.height);
    params.setPictureFormat(ImageFormat.JPEG);
    params.setJpegQuality(85);
    params.setFlashMode(Parameters.FLASH_MODE_ON);

    cameraInstance.setParameters(params);

Solution

  • Well, it seems as in moto x, flash operation works only with some combination of Camera preview size and Camera picture size. I used different combination and it worked.