Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

android - Delete a photo from camera intent

I have a camera intent to capture images for an application.It saves images on tick click. But on cross button click a image is also saved.

How to delete a photo from camera intent in android?

Please help me with a code snippet.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How to delete a photo from camera intent in android?

If you supplied EXTRA_OUTPUT in the ACTION_IMAGE_CAPTURE Intent, see if there is an image written to the location that you specified. If so, delete it.

You can also see if the Intent delivered to onActivityResult() contains a Uri. It is not supposed to, but some buggy camera apps put one there. If it does, and it has a file scheme, you could try deleting the underlying file.

Beyond that, the behavior of the user's chosen camera app is up to the developers of that camera app, not you. If you want that control, write your own camera code, using the camera APIs directly (e.g., android.hardware.Camera, android.hardware.camera2.*) or via wrapper libraries (e.g., Fotoapparat, CameraKit-Android).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...