Activity在横竖屏切换时会重先onCreate Activty,有时我们不需要重先onCreate,修改方法很简单:
在AndroidMainfest.xml文件中对应的Activity中添加:android:configChanges="orientation",
但是这个方法再SDK版本在13以上时没有效果,
所以在SDK13以上的版本修改方法是要在AndroidMainfest.xml 中添加:android:configChanges="orientation|screenSize"
原因SDK文档的说明如下:
Note: If your application targets API level 13 or higher (asdeclared by the minSdkVersion
and targetSdkVersion
attributes), then you should also declare the "screenSize"
configuration, because it also changes when a deviceswitches between portrait and landscape orientations.