When the activity of a change in orientation is destroyed and recreated.
In your manifest, add the following to your activity.
<activity android:name=".MyActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name"> //Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. //add screenSize for api 13 and above.
Now that one of these configurations changes, MyActivity does not restart. Instead, MyActivity receives an onConfigurationChanged () call. This method is passed to the Configuration object, which indicates the new device configuration.
http://developer.android.com/guide/topics/resources/runtime-changes.html
source share