How to fix app crash after calling setResult then finish from surfaceview with cameraapi2

123 Views Asked by At

App crash after reading camera output from cameraapi2 with surface view.

This is the code to get the image and submit to another controller.

        Intent resultIntent = new Intent();
        resultIntent.putExtra(ConstKeyVariables.strProfileImage, sImage);
        setResult(Activity.RESULT_OK, resultIntent);
    }

    this.finish();

This is my SurfaceView

mPreview = new CameraPreviewNew(this, id, CameraPreviewNew.LayoutMode.FitToParent,camera2id);
    LayoutParams previewLayoutParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//mLayout is the container
    mLayout.addView (mPreview, 0, previewLayoutParams);

This is my ondestroy

protected void onDestroy() {
    Log.e("CameraActivity", "Destroying");
    super.onDestroy();
    try {
        stopCameraPreview();
    }catch (Exception ex){
        //ignore
    }
    Log.e("CameraActivity", "Destroyed");
}
0

There are 0 best solutions below