标签:android style blog color io ar div sp art
Android开发调用系统闪光灯。
添加权限:
<!-- 调用闪光灯权限 --> <uses-permission android:name="android.permission.FLASHLIGHT" /> <uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.autofocus"/>
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. ^_^
标签:android style blog color io ar div sp art
原文地址:http://www.cnblogs.com/SomnusLove/p/3990167.html