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!
This is done as follows: Intent camera_intent = new Intent(MediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult(camera_intent, pic_id); Now use the onActivityResult() method to get the result, here is the captured image.
SurfaceView. This class is used to present a live camera preview to the user. MediaRecorder.
Run the application on an Android phone. Selecting "Take photo" will open your camera. Finally, the image clicked will be displayed in the ImageView. Selecting "Choose from Gallery" will open your gallery (note that the image captured earlier has been added to the phone gallery).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With