Search code examples
androidcameraandroid-camera-intent

Android: Camera not closing after accepting taken picture


we have a camera intent with an extra output. Code below:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        System.out.println("onActivityResult called");
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == CAMERA_CODE && resultCode == Activity.RESULT_OK){
            StorageController.readCardImage(activity,activity.getCurrentCard().getUUID());
            mImageView.setImageBitmap(bm);

        }
    }
    public void startCamera(){
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(StorageController.createCardImageFile(activity, activity.getCurrentCard().getUUID())));
        startActivityForResult(intent, CAMERA_CODE);

    }

The intent is starting (camera opening) and we are able to take a picture. But when we try to accept the taken picture (pressing check-button), the camera does not return to the starting activity. We are getting no errors.

What could possibly be the reason for this? Thanks for your answers.


Solution

  • What could possibly be the reason for this?

    The camera app that you are testing with has bugs. This happens. ACTION_IMAGE_CAPTURE delegates to any one of hundreds of camera apps, based on device and user. Some of those apps' developers do not test ACTION_IMAGE_CAPTURE very well.

    There is nothing that you can do about this, other than not use ACTION_IMAGE_CAPTURE.