本文介绍了Android的子活动和方向锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了相当多的搜索和试验/误码测试在试图让我的应用程序固定在纵向模式下不过我难倒就这一个。

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.

背景:该应用程序有一个主要活动,显示各种过渡效果的静态图像。它使用了一个子活动来显示的MediaPlayer因为SurfaceView(以显示影片剪辑必需)削弱的静止图像转换的显示性能。

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.

这两项活动都锁定在纵向模式下,这似乎工作pretty以及大部分。我的问题是,当孩子的活动结束,我身体有景观位置它暂时切换为横向模式,然后返回到肖像模式的设备。在这方面,我看到屏幕上的箭头,等上了,我不想这样。

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.

下面是转储从logcat的:

Here's dump from logcat:

D /光标(1357):cursor_rotate 0结果
I / WindowManagerService(1357):设置旋转为0,animFlags = 1结果
I / ActivityManager(1357):配置改变:{规模= 1.0 IMSI = 0/0 LOC = EN_US触摸= 3键= 1/1/2 NAV = 1/1的广州澳凌= 2的布局= 35 uiMode = 17以次= 1726}结果
D / main_activity(6851)的onActivityResult:0 结果
D / child_activity(6851):surfaceDestroyed名为结果
D /光标(1357):cursor_rotate 3结果
I / WindowManagerService(1357):设置旋转3,animFlags = 1结果
I / ActivityManager(1357):配置改变:{规模= 1.0 IMSI = 0/0 LOC = EN_US触摸= 3键= 1/1/2 NAV = 1/1广州澳凌= 1布局= 35 uiMode = 17以次= 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结果

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?

推荐答案

您可以设置此对Android清单,就这样answer建议:

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

这篇关于Android的子活动和方向锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:16