2012-06-10 4 views
0

내 앱에서 방향 변경 사항을 캡처하는 데 문제가 있습니다. 기기 방향을 바꿀 때 앱 양식이 다시 시작되는 것을 막고 싶습니다.기기 방향 변경시 onConfigChanged()가 호출되지 않음

내 앱에 3 개의 활동이 모두 있습니다 (세 번째는 FragmentActivity 임). 주요 사용자 상호 작용은 FragmentActivity를 통해 이루어집니다.

나는 매니페스트를 변경 한 있도록 모든 활동을 다음과 같은 특성을 가지고 : 나는 또한 방법의 모든 활동과 실제로 내가 포함되어있다라는지고 있는지 확인하기 위해 오버라이드 (override) 한

android:configChanges="orientation"

Log.i() 성명서는 아무 것도보고되지 않습니다.

현재이 기능을 에뮬레이터와 함께 테스트하고 있으며 CTRL + F12를 누르면 방향 변경이보고됩니다.

I/ActivityManager (67) 구성을 변경 {배율 = 1.0 IMSI = 260분의 310 LOC = ko 페이지 터치 = 3 키 = 2/2분의 1 탐색 = 3/1 orien = 1 개 레이아웃 = 34 uiMode = 17 seq = 10}

내가 뭘 만들고 있습니까? 에서

답변

6

: 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).

+1

나는 그냥 즉 내가 예상대로 아무 다시 시작 실제 장치에서 잘 작동났습니다. 어쩌면 에뮬레이터 문제일까요? – Kerry

+0

내 앱 타겟 API 레벨이 16 인 경우, android : configChanges = "orientation | screenSize"를 사용해야 함을 의미합니까? –

+0

최소 sdk 버전 10과 target sdk 버전 15가 있습니다. Android는 screenSize를 구성 변경 사례로 추가하는 것을 허용하지 않으며 화면 방향 변경을 활동에 위임하지 않습니다. 대상 SDK 버전을 10으로 변경하면 예상되는 기능을 다시 사용할 수 있습니다. 대상 버전 15를 유지하는 방법에 대한 아이디어는 있지만 화면 방향 변경 사항을 캡처 할 수 있습니까? 감사. –

관련 문제