title: WindowManager.DefaultDisplay.Rotation is always zero
body: <p>I'm working on a Xamarin Android app which runs for the most part in Portrait mode. However, now we are adding the functionality where if the user rotates the device they get another view in Landscape mode.</p>
  
  <p>My issue is that when I try to use the following code snippet, rotation always has the value SurfaceRotation.Rotation0 (i.e. 0) no matter how I rotate the device.</p>
  
  <pre><code>var windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast&lt;IWindowManager&gt;();
  var rotation = windowManager.DefaultDisplay.Rotation; // Always gives zero
  </code></pre>
  
  <p>I am executing this code in a FragmentView (inherits from a base class, which inherits from MvxFragment). I have managed to get some code working using an OrientationEventListener, as follows, but this isn't ideal. I want to tap into the default Android behaviour for rotating a device, not define my own range of angles if possible:</p>
  
  <pre><code>// This works!
  public override void OnOrientationChanged(int orientation)
      {
      if (app.IsPortrait &amp;&amp; ((orientation &gt;= 85 &amp;&amp; orientation &lt;= 95) || (orientation &gt;= 265 &amp;&amp; orientation &lt;= 275)))
      {
          Mvx.Trace("Send message to open new view in landscape mode");           
      }
      else if (!app.IsPortrait &amp;&amp; (orientation &lt; 85 || (orientation &gt; 95 &amp;&amp; orientation &lt; 265 ) || orientation &gt; 275))
      {
          Mvx.Trace("Send message to close the landscape view");      
      }
  }
  </code></pre>
  
  <p>I'm testing using a connected LGE Nexus 5 device and with a Samsung GT-19300 with the same results. Both devices have the Auto-rotate screen enabled. I do have a UI (as opposed to the issues <a href="https://stackoverflow.com/questions/14626066/getrotation-always-returns-zero" title="GetRotation always returns zero">in this thread</a>). I've added </p>
  
  <pre><code>android:configChanges="orientation"
  </code></pre>
  
  <p>to my manifest. Each view is set with the correct orientation when the Activity is declared (e.g. using ScreenOrientation = ScreenOrientation.Portrait). Have I missed anything?</p>
  
  <p>Thanks in advance!</p>
  
  <p>David</p>