I have an application where I use devices camera.
Now I only release camera in normal flow.
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
if(camera != null) {
camera.stopPreview();
camera.release();
}
}
Thus, then application exits in camera mode in unexpected way - i.e. Force Close (due to OutOfMemoryError
) - camera gets locked. And only way to release it is to restart device.
And after application is started I get:
RuntimeException: Fail to connect to camera service
How could I make sure, that camera is released in any case?