修改CameraManager类中的openDriver(SurfaceHolder holder)方法:
public void openDriver(SurfaceHolder holder) throws IOException { if (camera == null) { System.out.println("wanggsx openDriver camera = null"); camera = Camera.open(); if (camera == null) { throw new IOException(); } camera.setPreviewDisplay(holder); if (!initialized) { initialized = true; configManager.initFromCameraParameters(camera); } configManager.setDesiredCameraParameters(camera); FlashlightManager.enableFlashlight(); } else { System.out.println("wanggsx openDriver camera != null"); camera.setPreviewDisplay(holder);//此处为新增方法 } }
时间: 2024-11-04 22:12:58