Galaxy Nexus 上的 LED 手电筒可以通过什么 API 控制?
Android 的 LED 手电筒 API 问题太多了。我不敢再问另一个问题,但这里是……
使用经过考验的真实 FLASH_MODE_TORCH,我能够对我的三星 Galaxy SII 感到满意并打开 LED 闪光灯。在我朋友的 Galaxy Nexus 上,就没有这样的运气了。在我其他朋友的 Droid X 上也没有。
我注意到有相当多的设备似乎需要特定的本机 IOCTL 调用。 Galaxy Nexus 也是这种情况吗?我如何找到对其进行编程的参考?
我正在做标准的 FLASH_MODE_TORCH/"flash-mode"="torch", startPreview() 链。
有点令人失望的是,这个看似标准的 API 似乎并不那么通用。
So many LED flashlight API questions for Android. I'm afraid to ask yet another, but here goes..
Using the tried and true FLASH_MODE_TORCH I am able to achieve satisfaction with my Samsung Galaxy SII and get the LED flash turned on. On my friend's Galaxy Nexus, no such luck. Nor on my other friend's Droid X.
I'm noticing for a not insignificant number of devices specific native IOCTL calls seem to be required. Is this the case for the Galaxy Nexus? How do I find a reference to program it?
I am doing the standard FLASH_MODE_TORCH/"flash-mode"="torch", startPreview() chain.
Kind of disappointing that this seemingly standard API doesn't appear to be so universal after all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现有些设备需要 SurfaceView 来打开 LED。
您的 Activity 需要实现 SurfaceHolder.Callback:
surfaceview 必须可见,
android:visibility="invisible"
否则高度和宽度为 0 将不起作用。不幸的是我没有找到一个好的解决方案来隐藏它,所以我只是给它一个 1x1dip 的大小并将其放置在按钮下方..
**(扩展上面的段落[没有足够的代表来回复,但觉得它很有用])在当前内容视图的 XML 中的某个位置,你想要的:
如果你将它放在RelativeLayout中(首选),你也可以执行alignParentLeft/Bottom将其塞在角落里。此方法适用于我的 Galaxy Nexus,但它是 Droid X(无论如何都有 .621 更新)的一个已知问题(手机端),并且不适用于我的。很好的答案,蒂莫什!
What I found out is that some devices need a SurfaceView to turn on the LED.
Your activity needs to implement SurfaceHolder.Callback:
The surfaceview has to be visible,
android:visibility="invisible"
or a height and width of 0 won't work. Unfortunately I didn't find a good solution to hide it, so Ijust gave it a size of 1x1dip and positioned it underneath a button..
**(To expand on above paragraph [Don't have enough rep to reply, but felt it was useful]) Somewhere in the XML of your current Content View, you want:
If you have it inside a RelativeLayout (preferred), you can also do alignParentLeft/Bottom to tuck it in a corner. This method works for my Galaxy Nexus, but it's a known problem (phone-side) for Droid X (with the .621 update, anyway), and doesn't work on mine. Great answer, timosch!