I\'m facing to a problem with a Samsung Galaxy Tab. I want to use the camera flash as torch.
Does anyone know how to enable it ?
Hereby a code that works to
This is how I turn on and of the torch in LG Nexus 4 and Samsung Galaxy Ace 2.
public void changeTorch() {
try {
camera = Camera.open();
// try to open the camera to turn on the torch
Camera.Parameters param = camera.getParameters();
param.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(param);
camera.startPreview(); // needed for some devices
Log.v("BSW torch", "Torch ON");
} catch (Exception e) {
// if open camera fails, try to release camera
Log.w("BSW torch", "Camera is being used trying to turn Torch OFF");
try {
camera.release();
} catch (Exception ex) {
Log.e("BSF torch", "Error releasing camera");
}
}
}