开发者

Keep camera captured by an activity after picture taken

开发者 https://www.devze.com 2023-02-12 04:42 出处:网络
It is necessary for my application to keep the camera c开发者_JAVA百科aptured until released manually by an Activity (I realize this is bad practice, as no other applications will be able to use the c

It is necessary for my application to keep the camera c开发者_JAVA百科aptured 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消