I am trying to make a small android app were I want to turn on the flash light on my LG P970 without actually turning on the camera application. Is this possible because from what information I have gathered so far you need to run the camera app to turn on the light.
Asked
Active
Viewed 1.9k times
1 Answers
0
There are several Open-Source flashlight apps for Android out there. If you look at their source you can see how they use it
Camera mCamera;
/* [...] */
public void initCamera() {
/* see their source for more */
}
public void lightOff() {
if (hasSurface && hasCamera) {
mParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
mCamera.setParameters(mParameters);
}
}
public void lightOn() {
if (this.isShown() && hasCamera) {
if (mParameters == null) {
setParameters();
}
mParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(mParameters);
} else {
initCamera();
}
}