Android camera locked after force close

前端 未结 4 1891
不思量自难忘°
不思量自难忘° 2020-12-16 17:29

I have an application where I use devices camera.

Now I only release camera in normal flow.

@Override
public void surfaceDestroyed(SurfaceHolder surf         


        
4条回答
  •  感动是毒
    2020-12-16 18:34

    private void stopPreviewAndFreeCamera() {
    
    if (mCamera != null) {
        /*
          Call stopPreview() to stop updating the preview surface.
        */
        mCamera.stopPreview();
    
        /*
          Important: Call release() to release the camera for use by other applications. 
          Applications should release the camera immediately in onPause() (and re-open() it in
          onResume()).
        */
        mCamera.release();
    
        mCamera = null;
    }}
    

    do it like this.

提交回复
热议问题