![](/img/trans.png)
[英]Why should I need setRetainInstance or onSaveInstance if I can use android:configChanges=“keyboard|orientation|screenLayout”
[英]How should I use android:configChanges when determining orientation
目前我正在使用清單中的服務設置處理我的動態壁紙中的方向:
android:screenOrientation="sensor"
android:configChanges="orientation"
我聽說有人說我應該用:
android:screenOrientation="sensor"
android:configChanges="keyboard|orientation"
注意 - 我在onConfigurationChanged()
方法中使用了一些自定義代碼
我應該做的正確方法是什么?
android:configChanges列出活動將自行處理的配置更改。 在運行時發生配置更改時,默認情況下會關閉並重新啟動活動,但聲明具有此屬性的配置將阻止活動重新啟動。 相反,活動仍在運行,並調用其onConfigurationChanged()方法。
因此,如果您只需要管理旋轉,鍵盤標志就沒用了,因為文檔說:
“鍵盤”鍵盤類型已更改 - 例如,用戶已插入外部鍵盤
事件發生時調用onConfigurationChanged()
回調。 所以你的自定義代碼在回調自我中是正確的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.