I am trying to bind an event in Javascript to either the orientationchange or resize events in Android in order to change the width/height of some elements for my web app. In the event, I use window.innerHeight and window.innerWidth to get the current height and width of the window.

This works great on iOS and desktop devices, but on Android it seems that it calls this event before changing the values in the window variable. Therefore, when someone switches from portrait to landscape, I still get the values for portrait and therefore cannot resize correctly. Does anyone know what the problem is, and how I can fix it?