android:configChanges="locale"

android:configChanges="locale" html

以后在不退出应用的状况下切换到Settings里切换语言,发现该Activity仍是重启了。android

4.2中,app配置了configChanges locale属性后,当app处于后台,并无finish时,若是改变语言,并不会在resume时调用Activity重写的onConfigurationChanged函数。app

缘由是,4.2增长了一个layoutDirection属性,当改变语言设置后,该属性也会成newConfig中的一个mask位。因此ActivityManagerService(实际在ActivityStack)在决定是否重启Activity的时候老是判断为重启。
当在 android:configChanges 中同时添加locale和layoutDirection时,才会发生app指望的事情。
SDK文档中有:
"orientation" The screen orientation has changed — the user has rotated the device.

Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.ide

可是在locale中却没有说明。locale中应该也有和这个相似的说明。
相关文章
相关标签/搜索