Heim > Fragen und Antworten > Hauptteil
ringa_lee2017-04-17 11:11:58
Camera camera = Camera.open(); Parameters p = camera.getParameters();
//手电筒闪光开启 private void processOnFlash(){ p.setFlashMode(Parameters.FLASH_MODE_TORCH); camera.setParameters(p); camera.startPreview(); } //手电筒闪光关闭 private void processOffFlash(){ p.setFlashMode(Parameters.FLASH_MODE_OFF); camera.setParameters(p); camera.stopPreview(); }
注意的是要及时释放Camera
//及时释放 public void surfaceDestroyed(SurfaceHolder holder) { camera.setPreviewCallback(null); camera.stopPreview(); camera.release(); camera = null; }