原因:沒有在AndroidManifest.xml 中申明android:configChanges
android:configChanges
Lists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.
解決在AndroidManifest.xml中申明 android:configChanges=”locale”
但是還是不行:
因爲4.2增加了一個layoutDirection屬性,當改變語言設置後,該屬性也會成newConfig中的一個mask位。所以ActivityManagerService(實際在ActivityStack)在決定是否重啓Activity的時候總是判斷爲重啓。
需要在android:configChanges 中同時添加locale和layoutDirection。
總結:
android:configChanges=”locale|layoutDirection”