我可以在不使用android.hardware.Camera的情况下控制手电筒吗?
在 zxing1.6
条码扫描仪上使用前灯选项在我的 Nexus One 上不起作用。我需要能够在我的应用程序中使用手电筒,但不能同时运行两个相机实例。有没有办法在不访问相机的情况下使用手电筒?或者我可以以某种方式访问已在使用的相机吗?
我正在使用 Google IntentIntegrator.java
补丁来扫描条形码。
The use of front light option with zxing1.6
barcode scanner does not work on my Nexus One. I need to be able to use the flashlight in my app, but you can't have two instances of the camera running. Is there a way to use the flashlight without accessing the camera? Or can I somehow access a camera that is already in use?
I am using the Google IntentIntegrator.java
patch to be able to scan barcodes.
简短的回答是“不”;前置 LED 被控制为闪光模式,这是相机的一个属性。这是模式“火炬”。并且没有两个应用程序不能同时打开相机。
(更长的答案是,曾经有一个隐藏的 API,这是 Barcode Scanner 尝试访问的 API,但它不再在几乎任何设备上工作。您可以深入研究源代码以查看 FlashlightManager 。)
从 Android 2.x 开始,就有了这个用于打开灯的正确 API,并且 Barcode Scanner 的下一版本的测试版确实使用了它。您可以在此处尝试一下。
The short answer is "no"; the front LED is controlled as a flash mode, which is a property of the camera. It is mode "torch". And no two apps can't open the camera at the same time.
(A longer answer is that there used to be a hidden API for this, which is what Barcode Scanner tries to access, but it doesn't work on almost any device anymore. You can dig into the source code to see
FlashlightManager
.)Since Android 2.x there is this proper API for turning on the light, and the beta of the next version of Barcode Scanner does use it. You can try it here.