I am creating a mobile website what detects orientation change and then chooses a callback based on the new width. The problem is, that the window.width does not update after onorientionchange with Android. It works on iOS, but not Android. Below is my example:
var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function() {
alert(window.orientation + " " + window.width);
}, false);
On Android the alert shows the correct orientation value, but the window.width is still the window size before the orientation change.
Not sure if you can refresh it, but as a work around you could determine if you are in portrait or landscape then use width as height and height as width or vice versa.
getResources().getConfiguration().orientation will give you the current orientation.