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. 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. Even then, I can only get the LEDs to turn on. They only turn off if the phone is put on hold, and doing so br开发者_运维问答eaks 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.
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
In 2.1 your app will require root permissions, whereas in 2.2 it can request "Flashlight" permission from the OS.
See the code of lamppu: http://code.google.com/p/lamppu/source/browse/jni/lamppu.c
精彩评论