I pointed out that my activity should be tied to a landscape that works most of the time. In particular, when an activity is already running, and I start a new instance from Eclipse , the activity starts with “Portrait” and immediately changes to “Landscape”, but not before the view already says that it is a Portrait. Thus, my view is initialized as "Portrait", but immediately gets the "Surface" property.
My manifest states the following:
<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
I also tried:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
When I aimed at API level 7, I believe this worked fine. Now I am aiming at the API8 level, and a strange quirk has appeared.
In the oncreate method, the value is:
getResources().getConfiguration().orientation
is an:
Configuration.ORIENTATION_PORTRAIT
Immediately after creating the Activity, the orientation changes to Landscape, I get surfacechanged , and I can "fix" everything. But why is it ever a portrait?
I suspect that this is due to the fact that the application is autorotated as it starts from the portrait screen. It seems strange that the application, which was instructed to NEVER be in the portrait, starts this way, and then quickly changes.
But is there a way to prevent him from ever being in a portrait?
I put this in my onCreate activity:
while (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }
This led to him being stuck there forever :)