0

We have an app written in c# with xamarin and all activities are forced in portrait mode. However this gives some orientation issues when recording an video. The meta data is wrong when the video is recorded in landscape mode. I tried using these methods.

Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        Camera.GetCameraInfo(_currentCamera, cameraInfo);

        var surfaceOrientation = WindowManager.DefaultDisplay.Rotation;

However they provide a fixed angle no matter how the device is turned. How can I get the actual device orientation even though the activity is fixed in portrait mode?

Bjarke
  • 1,283
  • 11
  • 36

1 Answers1

1

I believe you should be able to get the Orientation based on the Resources.Configuration.Orientation in which it will specify a value of Android.Content.Res.Orientation.Landscape or Android.Content.Res.Orientation.Portrait

http://androidapi.xamarin.com/index.aspx?link=T%3AAndroid.Content.Res.Orientation

http://developer.android.com/reference/android/content/res/Configuration.html#orientation

Otherwise if you can't keep track of the Orientation this way, you might need to write a OrientationListener based on the following SO post:

How to detect my screen orientation in portrait locked screen in android?

Community
  • 1
  • 1
Jon Douglas
  • 13,006
  • 4
  • 38
  • 51
  • 1
    Hi Jon Excellent answer. However the use of configuration does not work it still gives the fixed orientation. I had already started implementing a orientationlistener so your post ensured me it was the right way to go :) – Bjarke Mar 20 '15 at 18:25