As I understand it, if you insert 'android:configChanges="orientation"' into the activity in the manifest, the activity will not be destroyed and recreated on an orientation change. To test this, I created a dead-simple app which does NOTHING. Then I inserted 'android:configChanges="orientation"' in the manifest. Then I added the following method:
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.v(TAG,"onConfigurationChanged:");
super.onConfigurationChanged(newConfig);
}
However, I'm still seeing onCreate() being called. The activity is still being recreated.
As if that weren't strange enough, I don't see onConfigurationChanged() being called when I put the emulator into landscape mode (Ctrl-F11). It's only called when I go back to portrait mode. Shouldn't it be called both ways? Isn't the configuration (orientation) being changed when I go into landscape as well as portrait modes? This makes no sense.
Anyway, this whole activity and orientation thing is driving me crazy.
Your screen size changes from 1200x800 to 800x1200 (for instance).
Since API 13, this will also raise a screenSize
config change. The fix is:
android:configChanges="keyboardHidden|oritentation|screenSize"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With