This question already has answers here:
How to turn on front flash light programmatically in Android?
                                
                                    (11个答案)
                                
                        
                                上个月关闭。
            
                    
我用谷歌搜索找到用作手电筒的前闪光灯,但找不到任何答案。
有没有办法?
如何 ?

最佳答案

打开前置摄像头手电筒的示例:


CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String cameraId = cameraManager.getCameraIdList()[1]; //Id 1 is front camera
cameraManager.setTorchMode(cameraId, true);

07-24 12:29