android:configChanges="keyboardHidden|orientation"配置

一般在AndroidManifest.xml文件中都沒(méi)有使用到android:configChanges="keyboardHidden|orientation"配置,當(dāng)然還是很有用的。

就是如果配置了這個(gè)屬性,當(dāng)我們橫豎屏切換的時(shí)候會(huì)直接調(diào)用onCreate方法中的onConfigurationChanged方法,而不會(huì)重新執(zhí)行onCreate方法,那當(dāng)然如果不配置這個(gè)屬性的話就會(huì)重新調(diào)用onCreate方法了

android:configChanges=["mcc", "mnc", "locale",

"touchscreen", "keyboard", "keyboardHidden",

"navigation", "screenLayout", "fontScale", "uiMode",

"orientation", "screenSize", "smallestScreenSize"]

mcc:The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC.

IMSI(國(guó)際移動(dòng)用戶識(shí)別碼)發(fā)生改變,檢測(cè)到SIM卡,或者更新MCC

mnc:The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC.

IMSI網(wǎng)絡(luò)發(fā)生改變,檢測(cè)到SIM卡,或者更新MCC

其中mcc和mnc理論上不可能發(fā)生變化

locale:The locale has changed — the user has selected a new language that text should be displayed in.

語(yǔ)言發(fā)生改變,用戶選擇了一個(gè)新的語(yǔ)言,文字應(yīng)該重新顯示

touchscreen:The touchscreen has changed. (This should never normally happen.)

觸摸屏發(fā)生改變,這通常是不應(yīng)該發(fā)生的

keyboard:The keyboard type has changed — for example, the user has plugged in an external keyboard.

鍵盤(pán)類型發(fā)生改變,例如,用戶使用了外部鍵盤(pán)

keyboardHidden:The keyboard accessibility has changed — for example, the user has revealed the hardware keyboard.

鍵盤(pán)發(fā)生改變,例如,用戶使用了硬件鍵盤(pán)

navigation:The navigation type (trackball/dpad) has changed. (This should never normally happen.)

導(dǎo)航發(fā)生改變,(這通常不應(yīng)該發(fā)生) 舉例:連接藍(lán)牙鍵盤(pán),連接后確實(shí)導(dǎo)致了navigation的類型發(fā)生變化。因?yàn)檫B接藍(lán)牙鍵盤(pán)后,我可以使用方向鍵來(lái)navigate了

screenLayout:The screen layout has changed — this might be caused by a different display being activated.

屏幕的布局發(fā)生改變,這可能導(dǎo)致激活不同的顯示

fontScale:The font scaling factor has changed — the user has selected a new global font size.

全局字體大小縮放發(fā)生改變

orientation:The screen orientation has changed — that is, the user has rotated the device.設(shè)備旋轉(zhuǎn),橫向顯示和豎向顯示模式切換。

screenSize: 屏幕大小改變了

smallestScreenSize: 屏幕的物理大小改變了,如:連接到一個(gè)外部的屏幕上

4.2增加了一個(gè)layoutDirection屬性,當(dāng)改變語(yǔ)言設(shè)置后,該屬性也會(huì)成newConfig中的一個(gè)mask位。所以ActivityManagerService(實(shí)際在ActivityStack)在決定是否重啟Activity的時(shí)候總是判斷為重啟。

需要在android:configChanges 中同時(shí)添加locale和layoutDirection。

在不退出應(yīng)用的情況下切換到Settings里切換語(yǔ)言,發(fā)現(xiàn)該Activity還是重啟了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容