这是开启和关闭闪光灯的代码,在Android5.0上闪光灯正常,7.0点开启没反应,点关闭闪一下就没了。
flashlight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{ // TODO Auto-generated method stub
if (!isopent)
{ camera = Camera.open();
Camera.Parameters params = camera.getParameters(); params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); camera.setParameters(params); camera.startPreview();
isopent = true;
} else {
camera.stopPreview();
camera.release();
isopent = false;
}
}
});