Friday, April 20, 2012

More on the AIR 3.2 orientation bug(s)

Back again with another fix...

In my last post Fixing the fullscreen orientation bug in AIR 3.x I mentioned how to fix the fullscreen AIR issue when changing orientation.

What has now come to light is that while that issue is fixed, there are still issues with orientation changes.

The problem I found is that an orientation change from portrait to landscape works, but orientation back to portrait fails indeterminately: sometimes the app would re-orient and sometimes not.

After a significant amount of research I discovered that a missing value in the android:configChanges attribute on the main Activity seems to be the cause of this.

From Android 3.2 an additional value: "screenSize" is available and should be responded to if your are handling config changes yourself with respect to screen orientation.

To fix this, follow the steps in the previous post but also change the android:configChanges attribute to:

android:configChanges="keyboardHidden|orientation|screenSize"


Additionally it seems that APKTool can be unreliable in repacking the APK.
A work around for this follows:
  1. Unpack using APKTool.
  2. Make appropriate manifest changes.
  3. Re-pack to a temporary apk.
  4. Remove the AndroidManifest.xml from your original APK.
  5. Remove the contents of the root/META-INF folder from your original APK.
  6. Extract the fixed AndroidManifest.xml from the re-packed APK and add it to the root of the original APK.
  7. Re-sign the original APK as per the previous post.

This will preserve all resources, effectively just swapping out the manifest.
These fixes seems to have reliably solved the orientation bugs.

No comments:

Post a Comment