Orientation change in Honeycomb

2019-01-23 03:46发布

问题:

I have an activity that shouldn't be recreated after an orientation change. I added the following to the activity declaration in the manifest:

android:configChanges="orientation"

On Android 2.3 this works perfectly. On HONEYCOMB_MR2 onCreate is called anyway when change the orientation.

Is there something else that needs to be done on HONEYCOMB_MR2 to prevent recreating the activity after an orientation change?

回答1:

Apparently using orientation|screenSize (?) prevents onCreate on Honeycomb and (so far) does not seem to break anything in previous Android versions.

android:configChanges="orientation|screenSize"

No idea why this is necessary and I don't really understand the documentation about this new value.

I suspect that in HONEYCOMB_MR2 upon an orientation change the activity considers this as two config changes: orientation and screen size. And both attempt to recreate the activity by default.