google / cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Apache License 2.0
4.74k stars 1.03k forks source link

How to start the cameraview again after stop? #167

Closed SunnyLin2008 closed 7 years ago

SunnyLin2008 commented 7 years ago

When i stop the camera one time, and try to start it again,the cameraview can see notting with black background . How can i start the cameraview again after stop? Thank`s

eth0izzle commented 7 years ago

I had the same problem and couldn't figure out why. I think it's a layout issue as swaping cameras (from > back) is the same as calling stop() and start() again. I tried invalidating/redrawing layouts but just couldn't get it to work. My work around for now is programmatically new up the CameraVieweach time - works pretty well. When you call camera.stop() make sure to call removeView(camera) on it's parent view.

SunnyLin2008 commented 7 years ago

Thank's eth0izzle.I also resolution the problem with remove the cameraView befor stop it.