Question

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

Was it helpful?

Solution

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

OTHER TIPS

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.

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