android:configChanges="locale"

來源:互聯網
上載者:User

標籤:android   style   http   io   strong   ar   div   cti   

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中應該也有和這個類似的說明。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.