protected void onResume() {
super.onResume();
// TODO Auto-generated method stub
if (camera == null) {
camera = Camera.open();
camera.startPreview();
camera.setErrorCallback(new ErrorCallback() {
public void onError(int error, Camera mcamera) {
camera.release();
camera = Camera.open();
Log.d("Camera died", "error camera");
}
});
}
if (camera != null) {
if (Build.VERSION.SDK_INT >= 14)
setCameraDisplayOrientation(context,
CameraInfo.CAMERA_FACING_BACK, camera);
preview.setCamera(camera);
}
}
Caused by: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.<init>(Camera.java:545)
at android.hardware.Camera.open(Camera.java:403)
at info.androidhive.tendigimrapp.activity.CameraDemo.onResume(CameraDemo.java:93)
when i launch first time this Actvity then this Exception not coming when i come back previous actvity and we go cameraDemo Actvity then this Exception coming please tell me how to fix this Error i have tried but not able to fix excepiton coming at camera = Camera.open();
答案 0 :(得分:0)
添加
public void onStop() {
if (mCamera != null) {
mCamera.release();
}
}