拍照后保持相机捕捉到活动
我的应用程序有必要保持相机捕获,直到由活动手动释放为止(我意识到这是不好的做法,因为没有其他应用程序能够使用相机)。我过去可以通过避免 CameraPreview 中的 surfaceDestroyed 函数中的camera.release() 调用来做到这一点,但这在 2.1 后不再有效。
有什么办法可以让相机保持在圈养状态,而不会在表面毁坏后自动释放吗?
作为一个替代前一个问题的解决方法,有没有办法在服务内拍照,而不会使预览视图膨胀?
It is necessary for my application to keep the camera captured until released manually by an Activity (I realize this is bad practice, as no other applications will be able to use the camera). I used to be able to do this by avoiding the camera.release() call in the surfaceDestroyed function from CameraPreview, but this no longer works after 2.1.
Is there any way to keep the camera in captivity, without it being automatically released after surfaceDestroyed?
As a workaround question to answer instead of the previous one, is there any way to take a picture from within a service, without the preview view inflated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用camera.lock()来重新获取相机硬件上的锁。如果失败,您可以重新打开相机。
然而,这样做的缺点比阻止其他应用程序访问相机要糟糕得多。这也会快速耗尽电池电量,因为它会保持相机传感器和 DSP 的供电。根据此帖子,这可能会杀死电池在两个小时内就没电了。
You may be able to call camera.lock() to re-obtain the lock on the camera hardware. Failing that you can reopen the camera.
However, the drawback to this is much worse than preventing other apps from accessing the camera. This will also rapidly drain the battery, because it keeps the camera sensor and DSP powered. According to this thread, that could potentially kill a battery dead in two hours.