Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus 5 (4.4.2) Flashlight LED not turning on

I wrote a simple flashlight app that I've tested on an HTC Sensation, Nexus 7, HTC One, Moto X, Galaxy S3, Galaxy S4, and a Nexus 5. The only one that it doesn't work on is the Nexus 5. It doesn't throw an exception so finding out what's wrong is proving difficult.

Here's the code I've been using that works on everything but:

            sCamera = Camera.open();
            sParameters = sCamera.getParameters();
            sParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
            sCamera.setParameters(sParameters);
            sCamera.startPreview();

And here's a screenshot of what happens in LogCat when it should be turning the LED on: http://i.imgur.com/vXn5PoH.png

I've pulled the list of flash modes from the Nexus 5 and it says they are: on, off, auto, torch, and red-eye. These are as expected. I've tested with flipping between on, off, and torch, but nothing even makes the light flicker. And I know the LED isn't broken because other flashlight apps work fine.

like image 308
Zeek Aran Avatar asked Jan 28 '14 21:01

Zeek Aran


People also ask

Why is my flashlight light not working?

Restart the phoneIf a particular app or process is conflicting with the flashlight, then a simple reboot should fix it. Just hold the power button and select “Power off” from the menu. Now wait 10-15 seconds and turn it back on. This should fix the problem in most cases.

How do I fix my Android flashlight?

One of the most common solutions for the problem of flashlight not working is clearing the camera's data and cache. This will reset the system of the camera application. One drawback of this process is that once you delete the data, it will reset the settings of the camera to original settings.

How do you unlock a flashlight?

If you have an Android that doesn't offer shortcuts, you'll be able to access the flashlight in the Quick Settings panel when you swipe down from the top of your screen.


1 Answers

This sounds exactly like Syed mentions... try setting a surface view as follows:

    try {
        sCamera.setPreviewTexture(new SurfaceTexture(0));
    } catch (IOException ex) {
        // Ignore
    }
like image 50
appmattus Avatar answered Oct 03 '22 02:10

appmattus