简体   繁体   English

是否可以直接在Android中访问相机的LED?

[英]Is it possible to access the camera's LEDs directly in Android?

I'm still pretty new to using Android, but I decided that my first application would be a simple flashlight app for my new Incredible. 我仍然是使用Android的新手,但我认为我的第一个应用程序将是我的新Incredible的简单手电筒应用程序。 Unfortunately, it seems to be more difficult than I had originally thought. 不幸的是,它似乎比我原先想象的更难。

It seems that there's no way to access the LEDs through the SDK, at least not without a bunch of weird hacks to make the phone pretend that it's taking a picture. 似乎没有办法通过SDK访问LED,至少不是没有一堆奇怪的黑客让手机假装它正在拍照。 Even then, I can only get the LEDs to turn on. 即使这样,我也只能打开LED。 They only turn off if the phone is put on hold, and doing so breaks all camera-related apps until the phone is rebooted. 它们仅在手机处于待机状态时关闭,这样做会破坏所有与相机相关的应用程序,直到手机重新启动。

So, I was wondering if accessing the LEDs through the NDK was possible, or if there was any other camera-related APIs that would seem to do what I want. 所以,我想知道是否可以通过NDK访问LED,或者是否有任何其他与相机相关的API似乎可以做我想要的。

I've looked at other code for other flashlights, so it looks like it's a hardware-based problem. 我看过其他手电筒的其他代码,所以看起来这是一个基于硬件的问题。 I figured I'd give up because it doesn't appear to be possible, but I thought I should ask here first on the off-chance somebody knows something that I don't. 我想我会放弃,因为它看起来似乎不太可能,但我想我应该先问一下这个机会,有人知道我不知道的事情。

On the nexus one you can control the LED with native code by doing ioctl()'s on /dev/msm_camera/config0 在nexus上,您可以通过在/ dev / msm_camera / config0上执行ioctl()来使用本机代码控制LED

In 2.1 your app will require root permissions, whereas in 2.2 it can request "Flashlight" permission from the OS. 在2.1中,您的应用程序将需要root权限,而在2.2中,它可以从操作系统请求“Flashlight”权限。

See the code of lamppu: http://code.google.com/p/lamppu/source/browse/jni/lamppu.c 请参阅lamppu的代码: http//code.google.com/p/lamppu/source/browse/jni/lamppu.c

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

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