Question

Gone through several posts and threads on configuration and orientation changes but still I am not cleared.

As onConfigurationChanged being called only when orientation changes from landscape to portrait or either portrait to landscape(as name suggests), but is there any way to listen reverseLandscape or reversePortrait orientation changes through any kinda listers at any api level.

Or is it possible to listen rotation changes same like onConfigurationChanged ??

Any kinda help will be highly appreciated !!

Was it helpful?

Solution

You can use accelerometer and magnetic field sensors to calculate the device rotation and then call

getWindowManager().getDefaultDisplay().getRotation();  

when the rotation is at certain value. The way to calculate the rotation is at my answer How to measure the tilt of the phone in XY plane using accelerometer in Android

OTHER TIPS

You can retrieve which of the 4 orientations is currently active by calling

getWindowManager().getDefaultDisplay().getRotation();

Knowing when to call it can be tricky, as the system won't notify you if you go straight from portrait to reversePortrait for instance. The only way to achieve that is using the device's sensors. This article from the Android Developers Blog should help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top