Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera blank image is not deleted ! #309

Closed
mhrlive opened this issue Oct 26, 2020 · 2 comments
Closed

Camera blank image is not deleted ! #309

mhrlive opened this issue Oct 26, 2020 · 2 comments

Comments

@mhrlive
Copy link

mhrlive commented Oct 26, 2020

When I open camera, a blank image is created and is not deleted after I get back from camera !

Steps to Reproduce the Problem

1.open camera
2. go back or close App
3. the blank 0kb image is not removed from storage !

Specifications

  • Image Picker Version:2.4.1
  • Android OS: 10
  • Phone: Samsung Galaxy s9
@per-johansson-74
Copy link
Contributor

per-johansson-74 commented Mar 11, 2021

Not sure if this is helpful but I fixed it by changing
ImagePickerFragment.java

/**
     * Check if the captured image is stored successfully
     * Then reload data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_CAPTURE) {
            if (resultCode == RESULT_OK) {
                presenter.finishCaptureImage(getActivity(), data, getBaseConfig());
            } else if (resultCode == RESULT_CANCELED && isCameraOnly) {
                presenter.abortCaptureImage();
                interactionListener.cancel();
            }
        }
    }

to

} else if (resultCode == RESULT_CANCELED) { //removed isCameraOnly to get next part to tigger
                presenter.abortCaptureImage(getContext());

and in
DefaultCameraModule.kt

val imagePath = currentImagePath ?: return
        val file = File(imagePath)
        if (file.exists()) {
            file.delete()
        } else { //Added this else part since in api29+ we use mediastore we need to remove the canceled row from there.
            val uri = Uri.parse(currentUri)
            context.applicationContext.contentResolver.delete(uri, null, null)
        }

@esafirm if this is not helpful at all, just delete it, i have not tested this much just trying some quick and dirty changes to get the lib working in api29 and 30 targeting 30 for personal use.

@esafirm
Copy link
Owner

esafirm commented Jun 19, 2021

Got it @Nightfright will try to include this on 3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants