如何在Android中创建或快或慢的相机闪光灯闪烁信号
2016-06-18
展开全部
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;
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;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询