android - W/CameraBase﹕ An error occurred while connecting to camera: 0 on camera.open() call -


I am writing a camera app and whenever I call a camera. The open () app crashes and then I get this error:

w / camerabasei ?? There was an error connecting to the camera: 0

Here I am opening the camera:

  public zero getCameraInstance () {mCamera = Null; Try {mCamera = Camera.open (); // Attempt to get a camera example} Catch (exception E) {// Camera is not available (use or does not exist)}} Update   

:

If you are reading this please note that this is for the original camera API and does not apply to the latest version of the camera API (Camera 2).

You should use the Camera 2 API from this point because it has more functionality and it also has a better image processing pipeline.

The notification is valid only for leaving API 21 (Lollipop).

To use the following method,

 < android.hardware.Camera.open (int cameraId)   

You have to pass the camera ID, You can use the following method if you want a camera id

  Private AutoForFrontFacingCamera () {// front facing camera int number of cameras = camera.jetnumberoff cameras (); For (int i = 0; i   
  1. If the same camera has been opened by another application, then it will insert a runtime exception.

  2. You should call the release () when you use the camera, otherwise it will remain locked and will be unavailable to other applications.

  3. Your camera should only have a camera object activated for a particular hardware camera at a time.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -