简体   繁体   English

Nexus 5(4.4.2)手电筒LED无法开启

[英]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. 我写了一个简单的手电筒应用程序,我在HTC Sensation,Nexus 7,HTC One,Moto X,Galaxy S3,Galaxy S4和Nexus 5上进行了测试。唯一不起作用的是Nexus 5它没有抛出异常,因此找出错误证明是困难的。

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 这里是LogCat应该打开LED时发生的屏幕截图: 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. 我从Nexus 5中提取了闪光模式列表,它说它们是:开,关,自动,火炬和红眼。 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. 而且我知道LED没有坏掉,因为其他手电筒应用程序运行正常。

This sounds exactly like Syed mentions... try setting a surface view as follows: 听起来就像Syed提到的那样...尝试设置表面视图如下:

    try {
        sCamera.setPreviewTexture(new SurfaceTexture(0));
    } catch (IOException ex) {
        // Ignore
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM