title: cordova detecting orientation change
body: <p>the app I am currently working on needs to know the orientation of the device, so I use this code to detect orientationchange events:</p>
  
  <pre><code>window.addEventListener('orientationchange', function(){
      theApp.orientationChange();
  });
  </code></pre>
  
  <p>and this property to get the actual orientation value:</p>
  
  <pre><code>window.orientation
  </code></pre>
  
  <p>The problem: when switching between the 2 landscape modes, no event will be fired and the orientation stays at the now wrong 90 or -90 deg respectively.</p>
  
  <p>I'm testing on 2 Android devices, running 2.3.5 and 4.4.4, both show the same behavior.</p>
  
  <p>So, the questions are:</p>
  
  <ul>
  <li>is there a workaround for this? - how can this event be detected?</li>
  <li>does this bug shows only on Android, or are other platforms affected?</li>
  </ul>
  
  <p><strong>clarification</strong><br>
  I want my app to show the direction from the user's location to a target geolocation.  </p>
  
  <p>To do this I need to 2 different orientation informations:</p>
  
  <ol>
  <li>compass heading</li>
  <li>screen orientation</li>
  </ol>
  
  <p>To get the compass heading this plugin is used:</p>
  
  <pre><code>org.apache.cordova.device-orientation 0.3.10 "Device Orientation"
  </code></pre>
  
  <p>I use</p>
  
  <pre><code>navigator.compass.watchHeading
  </code></pre>
  
  <p>to get heading updates - this part is working.</p>
  
  <p>To make an arrow element pointing to the target location, the app needs to know not only the compass heading, but also the screen orientation (the 0, 90, -90 and 180 deg values from the window.orientation property).<br>
  But this window.orientation property will be wrong on the tested Android devices, when changing the device orientation from landscape 1 to landscape 2 directly, without going over portrait mode. In addition the orientationchange event is NOT fired in this case.</p>
  
  <p>The IOS sample code (btw: there is nothing IOS specific in the sample, the code SHOULD run in every WebView) KRIZTE is referencing relies on correct window.orientation values. The issue mentioned (delayed initial update) is not a problem with my code.</p>
  
  <p>(Test-)Code used to check window.orientation:</p>
  
  <pre><code>setInterval(function(){
      console.log('WO ' + window.orientation);
  }, 1000);
  </code></pre>
  
  <p>waiting for orientationchange events:</p>
  
  <pre><code>window.addEventListener('orientationchange', function(){
      console.log('window.orientation : ' + window.orientation);
  });
  </code></pre>
  
  <p>annotated Log:</p>
  
  <pre><code>[starting app]
  [check function returns correct value:]
  "WO 0"
  ...
  
  [change device orientation to landscape 1]
  [got orientationchanged event, value is correct]
  "window.orientation : 90"
  [check function returns correct value:]
  "WO 90"
  ...
  
  [change device orientation back to portrait]
  [got orientationchanged event, value is correct]
  "window.orientation : 0"
  [check function returns correct value:]
  "WO 0"
  ...
  
  [change device orientation to landscape 2]
  [got orientationchanged event, value is correct]
  "window.orientation : -90"
  [check function returns correct value:]
  "WO -90"
  ...
  
  [change device orientation to landscape 1]
  ...       &lt; Problem 1: no orientationchanged event
  "WO -90"  &lt; Problem 2: wrong window.orientation value, value should be +90 deg
  ...
  </code></pre>