3

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);

2 Answers2

2

Did you see : Camera FLASH_MODE_ON not working on Moto X ?

What is

Parameters param = mCamera.getParameters();
Log.i("camera", param.flatten().toString());

logging ? =)

Community
  • 1
  • 1
poulpi
  • 101
  • 7
  • I saw that post but it didn't help. I can enable torch mode by setting parmas.setFlashMode(Parameters.FLASH_MODE_TORCH) and it works. But setting flash mode to Parameters.FLASH_MODE_ON and Parameters.FLASH_MODE_AUTO doesn't work. – Lalit Mohan Jul 17 '14 at 09:05
  • Did you try using the flash with any alternative Camera App from Google Play on your device ? Maybe that Motorola completely screwed up the Camera API on the Moto X (as your code looks correct and is working on other devices) :/ – poulpi Jul 17 '14 at 14:18
  • Yes, alternative apps work. This is a problem with the camera API it appears. I am still stuck on this, and would love to hear if anyone else has been able to solve. – RealCasually Jul 21 '14 at 04:01
  • @RealCasually see my answer below. I am not sure though whether it is the only possible way and is it the only reason why flash is misbehaving. But it worked. – Lalit Mohan Jul 22 '14 at 06:53
1

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.