I am working on an app where all activities are set to:
android:screenOrientation="portrait"
Here is what happens:
Tablet is in portrait mode BEFORE the app starts:
- startScreen is created in portrait mode
- one navigates to another portrait screen
- one goes back to startScreen – it gets created in portrait mode – everything OK
And this is what happens when the tablet is in landscape mode when
the app starts:
- startScreen is created in portrait mode
- one navigates to another portrait screen
- one goes back to startScreen – it gets created in LANDSCAPE mode only to be immediately closed within a fraction of a second and the activity gets distroyed – then finally the activity gets created in porttrait mode
How can I avoid this creation in LANDSCAPE mode for a fraction of a second and immediately be created in portrait mode only?
Many thanks
Add in your manifest in the activity tag: android:configChanges=”orientation”. Now it will not restart in the orientation.
This is a theory only, but if you see your screen in landscape mode first you you can perhaps override your root view and override the onDraw method.
Check your canvas width and height.
If the height is bigger smaller than width don’t draw or set visibility false.
Until you receive the “right” canvas to draw upon.
It might be an overkill but I think it might be done.
Also look for more possible things that can change screen orientation here:
http://developer.android.com/guide/topics/manifest/activity-element.html#screen
There is another one from API 14 and up (I think) that caused me a lot of problem which is “ScreenSize”.