最近在做Camera相关的东西,由于以前没有接触过这方面的东西,在使用Camera的PreviewCallback的时候发现如下异常:
12-31 19:35:01.859: D/AndroidRuntime(6597): Shutting down VM
12-31 19:35:01.869: E/AndroidRuntime(6597): FATAL EXCEPTION: main
12-31 19:35:01.869: E/AndroidRuntime(6597): Process: com.intel.xiao.videorecoderdemo001, PID: 6597
12-31 19:35:01.869: E/AndroidRuntime(6597): java.lang.RuntimeException: Method called after release()
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.hardware.Camera.setHasPreviewCallback(Native Method)
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.hardware.Camera.access$600(Camera.java:141)
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1110)
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.os.Handler.dispatchMessage(Handler.java:102)
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.os.Looper.loop(Looper.java:135)
12-31 19:35:01.869: E/AndroidRuntime(6597): at android.app.ActivityThread.main(ActivityThread.java:5221)
12-31 19:35:01.869: E/AndroidRuntime(6597): at java.lang.reflect.Method.invoke(Native Method)
12-31 19:35:01.869: E/AndroidRuntime(6597): at java.lang.reflect.Method.invoke(Method.java:372)
12-31 19:35:01.869: E/AndroidRuntime(6597): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
12-31 19:35:01.869: E/AndroidRuntime(6597): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:669)
查找资料发现是如下原因:
使用 mCamera.setPreviewCallback(new PreviewCallback()) 后,在release Camera资源的时候,没有把该回调设为null