committedandroider
committedandroider

Reputation: 9291

Why does config changes have to listen for orientation and screen size for orientation changes?

I read somewhere and took notes(forgot the source) that starting android 11 HONEYCOMB, to listen to orientation changes, you have to do android:configChanges="orientation|screenSize". My question why do you also have to listen to screen Size changes? I mean if you have a tablet that is 400 by 600 px and you change the orientation, the new size will be 600 by 400 px. Can anyone explain the need to listen to screenSize?

Upvotes: 1

Views: 81

Answers (1)

matiash
matiash

Reputation: 55370

It's here:

Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.

The onConfigurationChanged() method is called if the activity declares that it will handle all the configurations that are actually changing. In Honeycomb, orientation is always accompanied by screenSize (and screenSize didn't exist previously). Therefore, if you only handle the orientation change, then the activity will be destroyed and recreated.

Also here, somewhat more explicit (but it's basically this reason).

Upvotes: 1

Related Questions