| Summary: | Erroneously Receiving SDL_APP_TERMINATING Event on Configuration Change | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Joe LeVeque <joeleveque> |
| Component: | *don't know* | Assignee: | Gabriel Jacobo <gabomdq> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | HG 2.1 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | SDLActivity.java patch to prevent SDL_APP_TERMINATING event on configuration change | ||
|
Description
Joe LeVeque
2013-12-11 18:21:47 UTC
Created attachment 1494 [details]
SDLActivity.java patch to prevent SDL_APP_TERMINATING event on configuration change
Related documentation: http://developer.android.com/reference/android/app/Activity.html#onDestroy() http://developer.android.com/reference/android/app/Activity.html#isFinishing() Also looks like isFinishing() is commonly used in onPause() to serve the same function: http://developer.android.com/reference/android/app/Activity.html#onPause() Do you have android:configChanges="orientation" in your AndroidManifest.xml ? I did not, because it never worked in the past, but after some research and trial-and-error I think I might have figured it out. Here's a long-winded explanation for posterity's sake: I had originally tried using: android:screenOrientation="landscape" android:configChanges="orientation" in AndroidManifest.xml to achieve what I wanted, but it never worked, so I had instead tried doing it programatically by calling: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) in Java. This appeared to do what I wanted, so I left it alone. However, using this method apparently causes Android not to call onConfigurationChanged() when configuration changes occur, but I guess it still calls onDestroy()?? I'm still not quite clear on what the actual behavior is/should be here. Anyway, after some research, I think I found the reason why android:configChanges="orientation" never worked. According to the Android documentation (http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange), beginning with Android 3.2, 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, you must declare android:configChanges="orientation|screenSize". After making this change, I now see that my overridden onConfigurationChanged() is being called, and onDestroy() is apparently no longer being called, thus I am no longer receiving the SDL_APP_TERMINATING event, and the configuration change seems to go get ignored as intended. Ok, thanks for the report! |