SirNick92
SirNick92

Reputation: 95

Android: Preview picture after capture, before save

I got a full camera app up and running, but I'd like to have the captured picture show on the screen before saving them (they're not going to the gallery). I've googled extensively and I can't find anything on the topic. I also have no idea how to start, so any advice or links to relevant information I didn't find would be wonderful. Thanks!

Upvotes: 6

Views: 2774

Answers (1)

devunwired
devunwired

Reputation: 63293

First of all, I'm assuming you are using the original Camera APIs, not Camera2. That functionality is really built into the preview capturing, so I'm assuming your code is just clearing the preview too quickly.

After calling Camera.startPreview() to render the live preview on the active surface, at some point Camera.takePicture() is called to trigger the image capture and the result is returned to the PictureCallback. As soon as the image is captured, the camera preview surface is frozen on that frame until it is restarted. So as long as you don't call Camera.startPreview() again inside of onPictureTaken() to restart that process, the SurfaceView will remain frozen on the frame you want the user to see already.

Then if they want to save, you can write the JPEG data to disk, and if not toss away the data.

Upvotes: 9

Related Questions