On some devices, onPreviewFrame
is not called if no SurfaceView
was set to display the camera preview.
However, I handle the camera in a service, so I can't set a SurfaceView
but I don't want to have visible preview anyway.
How can this be done? Can I programmatically create a SurfaceView
and set it with Camera::setPreviewDisplay
?
This must be possible or not?
It works on almost every phone without a SurfaceView
but not on HTC One X and Google Nexus One...
According to this question, creating a SurfaceView
in code works fine. Though I don't think you can create it through a service.
Another approach is to create a 1px-1px SurfaceView
inside a RelativeLayout
and hiding it with some other view on top of it. (visibility should still be VISIBLE
). We use this trick for Path camera UI where we render preview buffers through OpenGL and it works fine.
According to documentation readily configured, visible and displayed surface view is necessary to activate camera preview. It may be overlayued though
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