Method called after release Exception Camera preview

前端 未结 7 1317

I have one activity class(CameraActivity) which is using my CameraPreview class. In \"OnResume\" the camera and preview are initiated. In \"OnPause\", i am releasing camera

7条回答
  •  时光说笑
    2020-12-13 11:50

    My working solution: First: In CameraActivity class declare mCamera as array:

    Camera mCamera[] = new Camera[1];
    

    Second: declaration of the constructor CameraPreview must look like this:

    public CameraPreview(Context context, Camera[] camera,
                         PreviewCallback previewCb,
                         AutoFocusCallback autoFocusCb) {
          mCamera = camera;
          ...
    }
    

    But mCamera in CameraPreview class must be declared as follows:

    Camera[] mCamera; // without instantiating of the array!
    

    And finally: in both classes inside all the methods you should replace all references mCamera by mCamera[0]

    P.S: Sorry for my English

提交回复
热议问题