Delete picture taken from camera

Nightaye

I'm trying to delete the picture just taken by the app because I already saved it to my tmp folder for later use and I don't want the picture to show up in the gallery. Problem is that I can't figure out how to do it, I tried a bunch of things and now I'm stuck. This is my latest code (the data in the onActivityResult is null and I don't know why):

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == TAKE_PIC && resultCode == RESULT_OK) {
        Uri path = data.getData();
        new File(path.getPath()).delete();
        Toast.makeText(this, "Picture taken!", Toast.LENGTH_LONG).show();
    }
}

public void onButtonClick(View view) {
    CheckBox ckBox = (CheckBox) findViewById(R.id.cmark_picture);

    if (ckBox.isChecked())
        takePicture(view);
}

private void takePicture(View view) {
    tmpImg = new File(TMPDIR, "tmp.png");
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpImg));
    startActivityForResult(intent, TAKE_PIC);
}
Shadik Khan

Use below code for deleting the captured image after completion of your purpose

File casted_image = new File("path of image");
                if (casted_image.exists()) {
                casted_image.delete();
                }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to show Picture into a activity after taken and saved from custom camera

From Dev

Get uri of picture taken by camera

From Dev

Swift: How to Delete EXIF data from picture taken with AVFoundation?

From Dev

Android adding image to picture taken with camera

From Dev

picture taken with camera doesn't resize in uiimageview

From Dev

Upload a picture taken by the camera to a server with limited size

From Dev

Getting the URL of picture taken by camera with Photos Framework

From Dev

Strange size of picture taken with Android Camera

From Dev

Delete all images taken with specific camera

From Dev

Android Camera Preview Stretched in Preview, Not After Picture Taken

From Dev

Trying to display the picture in my app that was just taken with the built in camera app

From Dev

UIImagePickerController shows last picture taken instead of camera input

From Dev

How to set the size and quality of a picture taken with the android camera?

From Dev

Custom camera shows dark picture preview when photo taken on Nexus

From Dev

Android Camera: Get Picture Uri after the photo is taken

From Dev

Is there a way to specify the file name in advance for the picture taken with the flutter camera plugin?

From Dev

Decode datamatrix out of picture taken by camera2 with zxing

From Dev

Camera2 API picture taken wont show at gallery apps

From Dev

Picture taken with camera as div background image Ionic 3

From Dev

Weird picture taken from onPreviewFrame on Android

From Dev

Trying to display image taken from camera intent

From Dev

Set image taken from camera into an ImageView

From Dev

taken from android camera image original resolution

From Dev

Saving image taken from camera into INTERNAL storage

From Dev

Read thumbnail image taken from phone camera

From Dev

Rotating picture from android camera

From Dev

Images not being saved when picture is taken by camera app that isn't the stock camera

From Dev

put in a frame image taken from the camera or on own camera

From Dev

How to determine whether an image was taken from the library or from the camera

Related Related

  1. 1

    How to show Picture into a activity after taken and saved from custom camera

  2. 2

    Get uri of picture taken by camera

  3. 3

    Swift: How to Delete EXIF data from picture taken with AVFoundation?

  4. 4

    Android adding image to picture taken with camera

  5. 5

    picture taken with camera doesn't resize in uiimageview

  6. 6

    Upload a picture taken by the camera to a server with limited size

  7. 7

    Getting the URL of picture taken by camera with Photos Framework

  8. 8

    Strange size of picture taken with Android Camera

  9. 9

    Delete all images taken with specific camera

  10. 10

    Android Camera Preview Stretched in Preview, Not After Picture Taken

  11. 11

    Trying to display the picture in my app that was just taken with the built in camera app

  12. 12

    UIImagePickerController shows last picture taken instead of camera input

  13. 13

    How to set the size and quality of a picture taken with the android camera?

  14. 14

    Custom camera shows dark picture preview when photo taken on Nexus

  15. 15

    Android Camera: Get Picture Uri after the photo is taken

  16. 16

    Is there a way to specify the file name in advance for the picture taken with the flutter camera plugin?

  17. 17

    Decode datamatrix out of picture taken by camera2 with zxing

  18. 18

    Camera2 API picture taken wont show at gallery apps

  19. 19

    Picture taken with camera as div background image Ionic 3

  20. 20

    Weird picture taken from onPreviewFrame on Android

  21. 21

    Trying to display image taken from camera intent

  22. 22

    Set image taken from camera into an ImageView

  23. 23

    taken from android camera image original resolution

  24. 24

    Saving image taken from camera into INTERNAL storage

  25. 25

    Read thumbnail image taken from phone camera

  26. 26

    Rotating picture from android camera

  27. 27

    Images not being saved when picture is taken by camera app that isn't the stock camera

  28. 28

    put in a frame image taken from the camera or on own camera

  29. 29

    How to determine whether an image was taken from the library or from the camera

HotTag

Archive