[英]App is killed when I change orientation of lock screen before unlocking
我有游戲在橫向模式下運行。 當我按下鎖定按鈕然后再次解鎖時一切正常。 我還處理屏幕方向更改,如下所示:
<activity
android:configChanges="orientation|keyboard|keyboardHidden"
android:screenOrientation="portrait"
一切正常,只有一個例外:
=> app已關閉(無錯誤)
有誰知道如何處理這個? 在刷卡解鎖屏幕之前鎖定屏幕方向改變時如何防止或處理屏幕方向<
我相信你需要'screenSize'。 即使您處理“方向”更改,屏幕大小也會從X到Y由Y更改為Y,並且會計為屏幕大小更改。
<activity
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:screenOrientation="portrait"
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.