当我尝试使用下面的代码打开前置摄像头时,它没有在 camerapreview 类的 Surfaceview 上预览摄像头,有什么问题?
swicthToFrontCamera.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// Camera.g
mCamera.stopPreview();
mCamera.release();
// Camera getFrontFacingCamera() throws NoSuchElementException {
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
for (int cameraIndex = 0; cameraIndex < Camera
.getNumberOfCameras(); cameraIndex++) {
Camera.getCameraInfo(cameraIndex, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
try {
Camera.open(cameraIndex);
//mCamera.setPreviewDisplay(mCameraPreview);
mCamera.startPreview();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
}
}
});