How can I re-use a surfaceHolder with camera.startPreview after I've already taken a picture? [closed]

StackOverflow https://stackoverflow.com/questions/9506961

문제

RESOLVED : issue was unrelated to Android camera or SDK, but rather my own logic to determine whether the camera and surface are both ready.

I have a situation where I've got a SurfaceView that exists in an activity's layout xml, to which I add a callback so that I can know when the surfaceHolder is ready to act as a Camera preview window for my application. This part works just fine. I get a preview window and can use all the normal camera related methods and callbacks to take and store images.

The problem is that after the user has taken the picture they are prompted with a button that will allow them to immediately take another picture without first opening a preview window for the picture they've just taken... this is where my problem lies! When I try to call camera.startPreview a second time, with the already created surfaceHolder instance, I get no preview.

How can I re-use the same surfaceHolder? Is there some way I can perhaps force the surfaceView to destroy and re-create the current holder?

도움이 되었습니까?

해결책

Issue was ultimately not related to the capability of a surfaceHolder to be re-used as a camera preview on multiple photos in the same activity's lifetime. It was all down to my own logic that was checking whether the camera and holder were both indeed "ready".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top