簡體   English   中英

當設備方向更改時,不會調用onConfigChanged()

[英]onConfigChanged() NOT called when device orientation changes

我在捕獲應用程序中的方向變化時遇到問題。 我想防止重新定向設備時重新啟動我的應用程序表單。

我的應用程序中總共有3個Activity(第三個是FragmentActivity)。 主要的用戶交互是通過FragmentActivity。

我更改了清單,以便所有活動都具有以下屬性:

android:configChanges="orientation"

我還覆蓋了所有活動中的onConfigurationChanged()方法,並查看它是否真正被調用,我包括了Log.i()語句,但從Log.i()過任何報道。

我目前正在使用模擬器進行測試,並且在執行CTRL + F12時會報告方向更改。

I / ActivityManager(67):配置已更改:{scale = 1.0 imsi = 310/260 loc = zh_CN touch = 3鍵= 2/1/2導航= 3/1 orien = 1布局= 34 uiMode = 17 seq = 10}

我在想什么嗎?

來自: http : //developer.android.com/guide/topics/resources/runtime-changes.html

Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM