开发者

Android child activity and orientation lock

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.po开发者_开发百科rtrait.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?


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"/>`


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜