0

我在捕捉应用程序中的方向变化时遇到问题。我想防止在设备重新定向时重新启动我的应用程序表单。

我的应用程序中有 3 个活动(第三个是 FragmentActivity)。主要的用户交互是通过 FragmentActivity。

我已更改清单,以便所有活动都具有以下属性:

android:configChanges="orientation"

我还在onConfigurationChanged()所有活动中重写了该方法,并查看它是否真的被调用了,我包含了一个Log.i()声明,但没有报告任何内容。

我目前正在使用模拟器对此进行测试,并且当我执行 CTRL+F12 时会报告方向更改。

I/ActivityManager(67):配置更改:{ scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=10}

有什么我想念的吗?

4

1 回答 1

6

来自:http: //developer.android.com/guide/topics/resources/runtime-changes.html

Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

于 2012-06-10T08:47:23.300 回答