最近在做一个写卡项目,在插拔sim卡槽和写卡完成后总是会导致activity自动重启,引起写卡页面状态发生错乱。页面重启往往是由于configChange引起的,在android:configChanges中找到了这两个属性:
mcc:The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC.
IMSI(国际移动用户识别码)发生改变,检测到SIM卡,或者更新MCC
mnc:The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC.
IMSI网络发生改变,检测到SIM卡,或者更新MCC
由于这两个属性状态的变化才导致页面自动重启,于是在manifest中对activity添加配置:
android:configChanges="mcc|mnc"
这样页面就不会自重启了,而只是去回调onConfigurationChanged。