Reputation: 926
I want to have the flash on the phone turned on as well as the the front camera turned on while displaying the view. My current code does not turn on the flash even though it should camera
in the code refers to the front camera.
I believe this doesnt work because there is no flash associated with the front camera. My other way of doing this would be to open the front camera and turn its flash on, but to my knowledge that will be impossible since you can only have one camera open at a time and opening the rear camera will turn off the front camera and its display.
Parameters params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_ON);
camera.setParameters(params);
camera.startPreview();
camera.autoFocus(new Camera.AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
}
});
Upvotes: 3
Views: 2172
Reputation: 800
According to the android developer site your application should only have one Camera object active at a time for a particular hardware camera. In order to use the flash it must create an object of the back facing camera and therefore you need two camera objects created at once in order to do what you want to do. This is currently not supported. The latest samsung phones are able to do this however I presume they have rewritten all of androids camera methods.
http://developer.android.com/guide/topics/media/camera.html
http://developer.android.com/reference/android/hardware/Camera.html#open(int)
Upvotes: 0
Reputation: 6094
I think it should be possible.
OPTION #1: Try using the code from Torch, an Android flashlight application.
OPTION #2: According to this, some devices need a SurfaceView to turn on the LED.
Upvotes: 1