开发者

Android flash camera parameter not working

I've been searching for a few days but I can't find a way to set the flash mode of the camera in an HTC Wildfire. The same code works for the Nexus S. This is the code I am currently using.

//Code block to toggle flash setting between on and off 

Camera.Parameters param = mCameraDevice.getParameters();
flashModes = param.getSupportedFlashModes();

if (flashModes != null) {
    currentFlashMode = param.getFlashMode();

    if (currentFlashMode.equals(Parameters.FLASH_MODE_OFF)) {
       currentFlashMode = Parameters.FLASH_MODE_ON;
    }
    else {
       currentFlas开发者_C百科hMode = Parameters.FLASH_MODE_OFF;
    }

    param.setFlashMode(currentFlashMode);
    mCameraDevice.setParameters(param);
}

I have verified that even in the HTC Wildfire the if conditions are satisfied and set parameters gets called. Unfortunately it seems to have no effect and the default flash setting of the camera is always used.

The flash parameter is not set in any other part of the code. I've seen some apps successfully set the flash mode on the Wildfire, so I;m sure I'm doing some thing wrong. Any help would be greatly appreciated.


I know that HTC devices are using a different trick. Have a look at the following piece of code - http://www.java2s.com/Open-Source/Android/Tools/quick-settings/com/bwx/bequick/flashlight/HtcLedFlashlight.java.htm

It's taken from the quick-settings app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜