Reading device orientation
Although the Android framework will automatically load a new resource (such as the layout) upon orientation changes, there are times when you may wish to disable this behavior. If you wish to be notified of the orientation change instead of Android handling it automatically, add the following attribute to the Activity in the Android Manifest:
android:configChanges="keyboardHidden|orientation|screenSize"
When any of the following configuration changes occur, the system will notify you through the onConfigurationChanged()
method instead of handling it automatically:
keyboardHidden
orientation
screenSize
The onConfigurationChanged()
signature is as follows:
onConfigurationChanged (Configuration newConfig)
You'll find the new orientation in newConfig.orientation
.
Tip
Disabling the automatic configuration change (which causes the layout to be reloaded and state information to be reset) should not be used as a replacement for properly saving state information. Your application...