2

I've done quite a bit of searching and trial/error testing in trying to get my application fixed in portrait mode however I'm stumped on this one.

Background: This application has a main activity which shows static images with various transition effects. It uses a sub activity to show a MediaPlayer because the SurfaceView (required to show the movie clip) cripples the display performance of the still image transitions.

Both activities are locked in portrait mode and this seems to work pretty well for the most part. My issue is when the child activity finishes and I physically have the device in landscape position it temporarily switches to landscape mode then back into portrait mode. In doing so I see the arrows on the screen, etc, and I don't want this.

Here's dump from logcat:

D/cursor ( 1357): cursor_rotate 0
I/WindowManagerService( 1357): Setting rotation to 0, animFlags=1
I/ActivityManager( 1357): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=2 layout=35 uiMode=17 seq=1726}
D/main_activity( 6851): onActivityResult: 0
D/child_activity( 6851): surfaceDestroyed called
D/cursor ( 1357): cursor_rotate 3
I/WindowManagerService( 1357): Setting rotation to 3, animFlags=1
I/ActivityManager( 1357): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=1 layout=35 uiMode=17 seq=1727}
D/StatusBarPolicy( 1357): ro.wmt.ui.portrait.hide.capbtn = 1
D/StatusBarPolicy( 1357): wm.getRotation = 3
D/StatusBarPolicy( 1357): ro.wmt.ui.portrait.hide.capbtn = 1
D/StatusBarPolicy( 1357): wm.getRotation = 3

The only two lines I want to see are in bold, everything else I want to eliminate. Occasionally, the switch is seamless depending on timing so I'm guessing there's some sort of race condition?

rlc
  • 5,809
  • 5
  • 38
  • 46
user969956
  • 21
  • 4

2 Answers2

1

You can set this on the Android Manifest, just like this answer suggested:

<activity 
    android:name=".MyActivity" 
    android:screenOrientation="portrait"
    android:configChanges="orientation|keyboardHidden|keyboard"/>`
Community
  • 1
  • 1
rlc
  • 5,809
  • 5
  • 38
  • 46
  • See above. I tried this well before asking this question. When the sub-activity finishes, the device momentarily switches to landscape mode then back to portrait when the parent activity re-activates. If I use NOSENSOR, the device is locked in landscape mode and nothing will put it into portrait mode. Viewing the OS source code confirms this. – user969956 Oct 11 '11 at 23:51
0

You can disable orientation changes in your Activities. I asked a similar question here.

You can call:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);

to disable orientation changes.

Community
  • 1
  • 1
Christopher Perry
  • 38,891
  • 43
  • 145
  • 187
  • I've tried that. It does ignore the sensor but it also locks the display into landscape mode and ignores my request for portrait mode. – user969956 Oct 05 '11 at 00:34
  • It's almost as if when the child activity is finish()'d there's a moment of uncertainty about what the orientation should be. Sensor/NoSensor, requested orientation, etc of either activity is not considered for a brief moment during the destruction of the child activity. – user969956 Oct 05 '11 at 00:45
  • This explains a lot: http://boundarydevices.com/blogs/set-android-default-orientation-to-portrait-mode – user969956 Oct 05 '11 at 01:34