Android开发调用系统闪光灯。
添加权限:
private Camera camera = null;
private Parameters parameters = null;开启:
if (null == camera) { camera = Camera.open(); } camera.startPreview(); parameters = camera.getParameters(); parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);// 开启 camera.setParameters(parameters);
关闭:
if (camera != null) { parameters = camera.getParameters(); parameters.setFlashMode(Parameters.FLASH_MODE_OFF);// 关闭 camera.setParameters(parameters); camera.stopPreview(); camera.release(); camera = null; }
ok. ^_^