我有这个以纵向模式运行的应用程序,作为一个活动的一部分,我有一个相机对象作为片段运行。
我可以选择从前置摄像头切换到后置摄像头,使用后置摄像头拍照时一切都很好。
当我用前置摄像头拍照时,它们会被倒置180度。 现在我知道这可能与纵向模式中的方向有关,但是在横向模式中使用它会破坏我的应用程序的想法。
无论如何这可以修复,所以拍摄的照片与您在预览中看到的相同吗?
listener = new OrientationEventListener(this.getActivity(),SensorManager.SENSOR_DELAY_NORMAL){ @Override public void onOrientationChanged(int orientation) { // TODO Auto-generated method stub if (orientation == ORIENTATION_UNKNOWN) return; android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(mCurrentCamera, info); orientation = (orientation + 45) / 90 * 90; int rotation = 0; if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { rotation = (info.orientation - orientation + 360) % 360; } else { // back-facing camera rotation = (info.orientation + orientation) % 360; } if