Reputation: 21
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?
Upvotes: 0
Views: 1704
Reputation: 103
May be you use screen orientation in an activity. But another activity will be rotate. in below example ActivityA's orientation will not change but ActivityB will be rotate. If you write android:screenOrientation="portrait" in app tag and not mention anything in activity. It doesn't work anything. So please mention screenOrientation in activity.
<activity
android:name=".ActivityA"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ActivityB">
</activity>
Upvotes: 1
Reputation: 466
are you using android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|keyboardHidden"
inside your application or under activity
Upvotes: 1