我在横向模式下运行游戏。当我按下锁定按钮然后再次解锁时一切正常。我还处理屏幕方向更改,如下所示:
<activity
android:configChanges="orientation|keyboard|keyboardHidden"
android:screenOrientation="portrait"
一切正常,只有一个例外:
=&GT;应用已关闭(无错误)
有谁知道如何处理这个问题?在刷卡解锁屏幕之前锁定屏幕方向改变时如何防止或处理屏幕方向&lt;
答案 0 :(得分:1)
我相信你需要'screenSize'。即使您处理“方向”更改,屏幕大小也会从X到Y由Y变为Y,并且会计为屏幕大小更改。
<activity
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:screenOrientation="portrait"
答案 1 :(得分:1)
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 declare
`android:configChanges="orientation|screenSize".`
但是,如果您的应用程序的目标是API级别12或更低,那么您的活动始终会自行处理此配置更改(即使在Android 3.2或更高版本的设备上运行,此配置更改也不会重新启动您的活动。)
来源:
http://developer.android.com/guide/topics/resources/runtime-changes.html