Turn ON / OFF Flashlight using SurfaceView

巧了我就是萌 提交于 2019-11-28 12:18:28

A few things I can think of:

Remember to add the features and requirements on the manifest for a camera app:

<!-- Camera Requirement -->
<uses-feature android:name="android.hardware.camera" />

<!-- Camera Permissions -->
<uses-permission android:name="android.permission.CAMERA" />     

<!-- Features -->
<uses-feature android:name="android.hardware.camera.flash" />
<uses-feature android:name="android.hardware.camera.autofocus" />

If you want to use it as flashlight you can do what @yoah said:

parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH)

If not, to turn flash on which will come out when you take the picture, you use:

parameters.setFlashMode(Camera.Parameters.FLASH_MODE_ON)

I wrote a custom camera app recently, but haven't uploaded it to Github yet, it has all the basic functions working.

Try to use

parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH)

Setting FLASH_MODE_ON means that flash will show when taking a picture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!