solution:
按照网上说的,在Manifest中对应的Activity设置android:configChanges="orientation"就可以了,但是我试了半天还是不行。原来从API等级13开始还要再加一个"screenSize"才可以,即:android:configChanges="orientation|screenSize",至于在java代码中的onConfigurationChanged方法是没有要求一定要重载的,如果纯粹为了禁止onDestroy() -> onCreate()仅需要添加一句android:configChanges="orientation|screenSize"就可以了。
e.g.
AndroidManifest.xml
<activity
android:name=".MyActivity"
android:configChanges="orientation|screenSize" >
</activity>
Develop Reference
"orientation " |
The screen orientation has changed — the user has rotated the device.
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.
|
"screenSize " |
The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13. |
|