无法在Android应用中启动新活动

时间:2012-04-13 10:04:41

标签: android android-activity android-intent

我通过拍照并将其数据传递给活动来开始一项新活动。 由于某种原因,活动不会开始。 (或者可能需要很长时间) 像这样:

        cameraResult = new Intent(Activity.this, ResultActivity.class);

        final Camera.PictureCallback cameraSavePictureCallback = new Camera.PictureCallback() {

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {
            // TODO Auto-generated method stub
            cameraResult.putExtra("PictureData", data);
            cameraResult.putExtra("size", "10cm");
            startActivity(cameraResult);
        }
    };

    final ShutterCallback myShutterCallback = new ShutterCallback() {

        @Override
        public void onShutter() {
            // TODO Auto-generated method stub

        }
    };

    final Camera.PictureCallback myPictureCallback_RAW = new Camera.PictureCallback() {

        @Override
        public void onPictureTaken(byte[] arg0, Camera arg1) {
            // TODO Auto-generated method stub

        }
    };

    // Add a listener to the Capture button
    Button captureButton = (Button) findViewById(id.button_capture);
    captureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // get an image from the camera
            camera.takePicture(myShutterCallback, myPictureCallback_RAW, cameraSavePictureCallback);                
        }
    });

我在新活动中有一个断点而且它没有得到它们,所以问题不在活动中。

有人可以告诉我可能出现的问题,以及这是否是在新屏幕中显示图片的正确方法?

EDIT1:我忘了提到只有当我拍摄的照片根本不是黑色时才会发生这种情况。我的意思是,如果我遮住镜头并拍照,它就不会卡住

EDIT2:我在logcat中有错误

04-13 14:09:34.777: ERROR/JavaBinder(13009): !!! FAILED BINDER TRANSACTION !!!

1 个答案:

答案 0 :(得分:0)

dude更改为最终Camera.PictureCallback相机PictureCallback = new Camera.PictureCallback(){

    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
        // TODO Auto-generated method stub
        cameraResult = new Intent(Activity.this, ResultActivity.class);
        cameraResult.putExtra("PictureData", data);
        cameraResult.putExtra("size", "10cm");
        startActivity(cameraResult);
    }
};