Android 运行时错误,但逐步调试工作正常

Android 运行时错误,但逐步调试工作正常,android,camera,runtime-error,Android,Camera,Runtime Error,我写了一个android程序,在没有预览的情况下拍照。当我一步一步地调试它时,我的程序运行良好。但是,当我在执行模式下运行它时,程序不能按预期工作。没有保存图片,程序无法完成。此外,除非我重新启动手机,否则我无法在其他android应用程序(如照相机、摄像机)中使用我的相机。有人对这个问题有什么想法吗?拍照代码和记录的错误如下: 拍照代码: SurfaceView view = new SurfaceView(this); mCamera = Camera.open();

我写了一个android程序,在没有预览的情况下拍照。当我一步一步地调试它时,我的程序运行良好。但是,当我在执行模式下运行它时,程序不能按预期工作。没有保存图片,程序无法完成。此外,除非我重新启动手机,否则我无法在其他android应用程序(如照相机、摄像机)中使用我的相机。有人对这个问题有什么想法吗?拍照代码和记录的错误如下:

拍照代码:

    SurfaceView view = new SurfaceView(this);
    mCamera = Camera.open();
    Camera.Parameters p = mCamera.getParameters();
    p.setPictureFormat(PixelFormat.JPEG);
    mCamera.setParameters(p);

    try {
        mCamera.setPreviewDisplay(view.getHolder());
        mCamera.startPreview();
        mCamera.takePicture(null, null, mPictureCallback);
        mCamera.stopPreview();
        mCamera.unlock();
        mCamera.release();
    } catch (Exception e) {
        mCamera.stopPreview();
        mCamera.release();
        e.printStackTrace();            
    }
回调函数

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
          public void onPictureTaken(byte[] imageData, Camera c) {
               if (imageData != null) {
            StoreByteImage(mContext, imageData, 50,
                    "ImageName");
            finish();
        }
    }
};
}
logcat报告的错误:

ERROR/Adreno200-ES20(130): rb verson is SBA #24
ERROR/mm-camera(130): prepare snapshot: Aec not settle
ERROR/CameraService(130): mHardware->setOverlay() failed with status -2147483648
ERROR/mm-camera(130): camera_issue_command: get_picture error (Connection timed out): length 36, status 0 FD: 20 1
ERROR/QualcommCameraHardware3D(130): getPicture: CAMERA_OPS_GET_PICTURE ioctl failed!
ERROR/NotificationService(292): adbEnabled = false
ERROR/NotificationService(292): adbEnabled = true

有人能给点建议吗?提前谢谢你

这对你有用吗

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file = new File(Environment.getExternalStorageDirectory(),
                    currentTimeString + ".jpg");
            outputFileUri = Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, TAKE_PICTURE);

它不起作用。没有照片被拍摄并保存在sd卡上。而且相机的预览模式也启动了。是的,我不确定我发布的时候是否显示了预览,我想是的。我知道这段代码是用来拍照的(在手机和模拟器上经过测试和工作),所以可能还有其他东西在为你准备。您使用的是仿真器还是实际设备?