Reputation: 21
I have a different scenario. I have the camera input connected to the android device. As per the steps given, I have initialized the camera object and the display is working perfectly as excepted.
I have separate code for receiving the camera disconnect information from the underlying linux kernel. In that case, I have to close the camera. Again, if the camera is connected back, I have to make the display resume back.
Scenario 1: When the camera disconnect information is obtained, I tried following functions
Cameraobject.setPreviewCallBack(null);
CameraObject.stopPreview();
CameraObject.release();
Problem: The control loops within these functions.
Scenario 2: I have commented the above lines. Instead, in the code section which gets executed when the camera gets connected again I have called them.
Cameraobject.setPreviewCallBack(null);
CameraObject.stopPreview();
CameraObject.release();
Cameraobject = Camera.open(cameraID);
Problem: Here it gets a runtime error. Could not be connected to camera service.
Upvotes: 2
Views: 1428
Reputation: 738
add in manifest file
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Upvotes: 0
Reputation: 21551
Are you added appropriate permissions defined in your manifest.?
android.permission.CAMERA
Upvotes: 1