摘要android
android:configChanges屬性,oncreate被屢次調用。服務器
APP運行時,一些設備的配置可能會改變,如:橫豎屏的切換、鍵盤的可用性等會致使 Activity重啓,即oncreate會被再次調用, 若是oncreate方法中有向服務器請求的方法,那麼悲劇就會發生,至關於屢次請求。這也是項目測試中經過抓包發現的問題,所以查了下,瞭解了 android:configChanges屬性,能夠設置多個,中間用「|」號隔開。最經常使用的兩個屬性:測試
"orientation" (屏幕方向改變了)和"keyboardHidden" ( 鍵盤的可用性發生了改變)。ui
詳細使用 在manifest中:it
<activity
android:name=".ui.FeedBack"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/Theme.HalfTranslucent"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />io