SopheakVirak
SopheakVirak

Reputation: 961

activity is restart when screen is rotate

I wonder why android:configChanges="orientation" could not work for android version 4.0.3. When the screen is rotate the activity restart.

Please kindly help on this matter.

Rgds, Virak

Upvotes: 3

Views: 448

Answers (2)

Marcin S.
Marcin S.

Reputation: 11191

Please also add screenSize like this:

android:configChanges="orientation|screenSize" 

That will solve your problem.

Upvotes: 7

Piyush Agarwal
Piyush Agarwal

Reputation: 25860

Apparently using orientation|screenSize (?) prevents onCreate on Android 4 and 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.

Upvotes: 0

Related Questions