Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
328 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 Reply

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...