I am trying to enable the Flash Light in SamSung mobile but its not getting turned on. here is my code
Camera mycam = Camera.open();
Parameters p = mycam.get
This is the workaround I use on my Samsung Galaxy Ace for the flashlight. I essentially continuously auto-focus the camera, because the LED only turns on during auto-focus.
AutoFocusCallback autoFocusCallback = new AutoFocusCallback();
autoFocusCallback.setHandler(handler, message);
//Log.d(TAG, "Requesting auto-focus callback");
camera.autoFocus(autoFocusCallback);
class AutoFocusCallback implements Camera.AutoFocusCallback {
private Handler autoFocusHandler;
private int autoFocusMessage;
void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
this.autoFocusHandler = autoFocusHandler;
this.autoFocusMessage = autoFocusMessage;
}
public void onAutoFocus(boolean success, Camera camera) {
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success)}
autoFocusHandler.sendMessage(message)
autoFocusHandler = null;
}
}
TORCH_MODE_ON would be preferable, but since it isn't supported, this is the best way I've found, if you simply must have the flashlight.