In my Android application, when I rotate the device (slide out the keyboard) then my Activity
is restarted (onCreate
is called). Now, this is proba
I just discovered this lore:
For keeping the Activity alive through an orientation change, and handling it through onConfigurationChanged
, the documentation and the code sample above suggest this in the Manifest file:
which has the extra benefit that it always works.
The bonus lore is that omitting the keyboardHidden
may seem logical, but it causes failures in the emulator (for Android 2.1 at least): specifying only orientation
will make the emulator call both OnCreate
and onConfigurationChanged
sometimes, and only OnCreate
other times.
I haven't seen the failure on a device, but I have heard about the emulator failing for others. So it's worth documenting.