美文网首页
Android Camera相机 Camera is being

Android Camera相机 Camera is being

作者: 木木禾木 | 来源:发表于2019-05-31 17:58 被阅读0次

    camera在切换前后摄像头时的异常

        Process: com.test.wrapper, PID: 8923
        java.lang.RuntimeException: Camera is being used after Camera.release() was called
            at android.hardware.Camera.setHasPreviewCallback(Native Method)
            at android.hardware.Camera.-wrap1(Unknown Source:0)
            at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1237)
            at android.os.Handler.dispatchMessage(Handler.java:105)
            at android.os.Looper.loop(Looper.java:173)
            at android.app.ActivityThread.main(ActivityThread.java:6698)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
    
    原因:

    缺少mCamera?.setPreviewCallback(null)
    果然调试代码时候还是要小心翼翼点儿啊...

           mCamera?.stopPreview()
           mCamera?.setPreviewDisplay(null)
           mCamera?.setPreviewCallback(null)
           mCamera?.lock()
           mCamera?.release()
           mCamera = null
    

    相关文章

      网友评论

          本文标题:Android Camera相机 Camera is being

          本文链接:https://www.haomeiwen.com/subject/maugtctx.html