android:configChanges="locale"

android:configChanges="locale"

之后在不退出应用的情况下切换到Settings里切换语言,发现该Activity还是重启了。

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

原因是,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.

但是在locale中却没有说明。locale中应该也有和这个类似的说明。

转载于:https://www.cnblogs.com/lyz459/p/3926693.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值