2

我有一个活动可以在触摸屏幕时拍照。拍完照片后,我想换个活动。代码的结构如下所示:

class MyActivity extends Activity implements onTouchListener {
    ...
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        mCameraView.takePicture();
        // Intent intent = new Intent(whatever);
        // startActivity(intent);
        return false;
    }
   }

如图所示,如果我将 注释掉startActivity,则正确拍摄并保存图片。如果我尝试在拍照后开始活动,则图片未正确保存(大小为 0)。我不确定拍照是否在单独的线程中,但即使是,它最终也应该保存,但似乎并非如此。知道如何解决这个问题吗?

4

1 回答 1

0

在结束时开始您的活动Camera.PictureCallback()

mCameraView.takePicture(new Camera.ShutterCallback() {

                    @Override
                    public void onShutter() {
                        Log.e("Shutter closed", "   SHUTTER    callback");

                    }
                }, new Camera.PictureCallback() {

                    @Override
                    public void onPictureTaken(byte[] arg0, Camera arg1) {
                        Log.e("Picture taken",
                                "   RAW    image    callback");
                    }
                }, new Camera.PictureCallback() {

                    @Override
                    public void onPictureTaken(byte[] arg0, Camera arg1) {
                        Log.e("Picture taken",
                                "   POSTVIEW    image    callback");
                    }
                }, new Camera.PictureCallback() {

                    @Override
                    public void onPictureTaken(byte[] data, Camera camera) {
                        // Start Activity here after saving image
                    }
                });


            }
        }
    };
于 2013-05-21T13:06:45.843 回答