1

首先,我想说我已经广泛研究了这个问题,我意识到这个网站(和其他网站)已经提出了很多解决方案,但绝对没有一个对我有用。

拍照后,我的应用程序允许用户将 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);
                }
            }           
        );
4

0 回答 0