if you try to open the camera using a camera ID that does not exist, you will get the same error (java.lang.RuntimeException: Fail to Connect to camera service)
look at your code on this block
camera.setParameters(parameters); camera.stopPreview(); camera.release(); camera = null;
Call release() to free the camera for use by other applications. Applications should immediately release the camera in onPause() (and reopen () in onResume().
In the above code, immediately after release, you put zero in the camera
Karim Baidar May 28 '14 at 7:26 a.m. 2014-05-28 07:26
source share