protected void onResume() {
super.onResume();
Log.d("OnResume", "Camera has been resumed");
try {
mCamera = Camera.open();
Log.d("OnResume", "Camera has been opened");
mCamera.startPreview();
Log.d("OnResume", "Camera has started preview");
preview.setCamera(mCamera);
Log.d("OnResume", "setCamera");
} catch (RuntimeException ex) {
Log.d("OnResume", ex.getMessage());
}
}
调用mCamera = Camera.open()时出错。它无法连接到摄像头服务。无需使用清单文件中的所有权限。
Error while opening the camera and camera services
D/OnResume﹕ Camera has been resumed.
W/CameraBase﹕ An error occurred while connecting to camera: 0.
D/OnResume﹕ Fail to connect to camera service
Getting error in inside try block. Have used the camera permission in manifest file.
答案 0 :(得分:0)
自我提示有关问题的错误,您在AndroidManifest.xml中添加了相机权限的错过:
<uses-permission android:name="android.permission.CAMERA" />
如果需要,还要添加uses-feature:
<uses-feature
android:name="android.hardware.camera"
android:required="false" />