I know the tile seems to be very confusing, but yeah, it happened to my application. Ok, here's the story.
Here's the key settings in Manifest:
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
In my Activity.java, I also override onConfigurationChanged(Configuration config)
, which will print out current orientation.
Here comes the most interesting part. I start a rotatable Application, say Gallery (assume it can rotate), from my application in landscape using Intent. Keep the phone in landscape, and press back key. The newly launched activity, in this case Gallery, will quit, and my application will restart. In theory, my application should display in portrait since I have set the screenOrientation
to portrait. However, in reality, my application just stays in portrait for 1 second, and then jumps to landscape, and jumps back to portrait again.
I start a thread to print out requestedOrientation
of my application after onRestart
is called. And I find out that the output is always "1", which is "portrait". Yet, the output from onConfigurationChanged
gives my a current orientation of landscape!
So, I'm totally confused. How can this happen? Can someone give me some advice?