Skip to content Skip to sidebar Skip to footer

Unable To Use The Flashlight In Galaxy Nexus

I have to following code and I just want to open the flashlight in my Galaxy Nexus(4.0.2) and it failed to do so. public class welcome extends Activity { //MediaPlayer player; /**

Solution 1:

The galaxy nexus is unable to use the flash without having an attached surfaceView and surfaceHolder. I have a Nexus myself, and after attaching the preview-view it worked. Since you dont want to see what the camera sees in a flashlight app, just make it 1x1 pixel.

Source: LED Flashlight does not work on Samsung Galaxy Nexus

Solution 2:

Have you tried the code here: http://android-er.blogspot.co.uk/2011/02/control-flash-light-function-as-torch.html

It definitely works on a rooted Desire running Cyanogenmod 7 and on an ICS rom (4.0.3) for me. Perhaps try running this and see if it works, and then proceed from there?

It also includes checks to see if it can find the camera, then open the camera. There seems to be no need for the StartPreview().

The order of events seems different:

1: If camera is present, open camera 2: Set parameters 3: parameters.setFlashMode(Parameters.FLASH_MODE_TORCH); 4: camera.setParameters(parameters);

Solution 3:

Use surface view to attach camera as some of the devices needs surface view. I am sure this will work a link! for you

Post a Comment for "Unable To Use The Flashlight In Galaxy Nexus"