2

onConfigurationChanged is called when the orientation of the device changes from portrait to landscape and vice versa. But it isn't called when the rotation of device changes from 90 to 270 and vice versa. They both are landscape.

Is there a function that's called when such an event occurs? I don't want to continuously check for rotation.

My app checks the rotation of the device in onConfigurationChanged. Works fine except for the one case I mentioned.

Would anyone know what should be done here? I searched a lot, couldn't find anything.

Thanks!

Rahul Sainani
  • 3,437
  • 1
  • 34
  • 48

1 Answers1

0

this will give you the rotation angle base from device's natural orientation, so in your onConfigurationChanged() method you should benefit from this``

Display display = ((WindowManager)     
context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int rotation = display.getRotation();
Onur A.
  • 3,007
  • 3
  • 22
  • 37
  • 5
    Hello Onur A, I have this in onConfigurationChanged(). The problem is onConfigChanged isn't called when the device's rotation changes from 90 to 270 or 270 to 90 - both are landscape. If we go from portrait to either type of landscape and back, then it's called. – Rahul Sainani Jul 13 '13 at 13:42