java.lang.RunTimeException:在恢复相机活动时在release()之后调用的方法

时间:2013-01-04 08:02:12

标签: android android-camera

首先,我想说我已经广泛研究了这个问题,并且我意识到在这个网站(以及其他网站)上提出了不少解决方案,但绝对没有一个对我有用。

拍照后,我的应用程序允许用户将Exif标签添加到照片中。添加数据后,我希望用户能够返回相机并继续拍照。然而,当我回到我的相机活动时,我尝试拍摄另一张照片时遇到上述java.lang.RunTimeException: Method called after release()错误。

现在我意识到这是因为我在发布相机后尝试使用相机,根据Android API,我需要重新open()onResume()中的相机} 方法。当我这样做时,我收到Failed to connect to camera service错误。 许多人还建议在mCamera.setPreviewCallback(null)方法中放置onResume(),但这也会导致Method called after release()错误。

这是我的logCat:

01-04 10:03:08.187: E/AndroidRuntime(1876): FATAL EXCEPTION: main
01-04 10:03:08.187: E/AndroidRuntime(1876): java.lang.RuntimeException: Method called      
                                            after release()
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.hardware.Camera.native_takePicture(Native Method)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.hardware.Camera.takePicture(Camera.java:789)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.hardware.Camera.takePicture(Camera.java:753)
01-04 10:03:08.187: E/AndroidRuntime(1876): at com.example.unititest.CameraActivity$6.onClick(CameraActivity.java:180)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.view.View.performClick(View.java:2485)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.view.View$PerformClick.run(View.java:9080)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.os.Handler.handleCallback(Handler.java:587)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.os.Handler.dispatchMessage(Handler.java:92)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.os.Looper.loop(Looper.java:123)
01-04 10:03:08.187: E/AndroidRuntime(1876): at android.app.ActivityThread.main(ActivityThread.java:3687)
01-04 10:03:08.187: E/AndroidRuntime(1876): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:03:08.187: E/AndroidRuntime(1876): at java.lang.reflect.Method.invoke(Method.java:507)
01-04 10:03:08.187: E/AndroidRuntime(1876): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
01-04 10:03:08.187: E/AndroidRuntime(1876): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-04 10:03:08.187: E/AndroidRuntime(1876): at dalvik.system.NativeStart.main(Native Method)

抛出错误的地方:

            // Add a listener to the Capture button
        Button captureButton = (Button) findViewById(R.id.button_capture);
        captureButton.setOnClickListener(
            new View.OnClickListener() 
            {
                @Override
                public void onClick(View v) 
                {
                    //Picture is taken and saved to file
                    //ERROR IS THROWN HERE  
                    mCamera.takePicture(null, null, mPicture);
                }
            }           
        );

0 个答案:

没有答案