Reputation: 6039
In my app i disable the auto-orientation but i still want to listen to orientation change method.
I tried overriding onConfigurationChanged
but i guess it's not called when auto-rotate is disabled.
I'm building on API 8 .
Thanks
Upvotes: 0
Views: 857
Reputation: 181
I use this code myself in my app:
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
int rotation = display.getRotation();
The value of rotation
can be as follows: 1 or 3 for landscape and 0 or 2 for portrait.
I'm not 100% sure if this will work if auto rotation is disabled, though, but you can give it a try.
Upvotes: 0
Reputation: 1294
I would take a look at how to read the accelerometer or gyroscope, to do this. I'm not really sure if this works or not, but that's how I would start out. Here's a link on how to use the accelerometer data.
http://www.techrepublic.com/blog/app-builder/a-quick-tutorial-on-coding-androids-accelerometer/472
Upvotes: 1