Android - Handling Screen Rotation
Word of warning before we start, this goes against the recommended Android UI Design Guidelines and should only be used when you are certain it is appropriate.
To handle screen rotations such that your activity doesn’t get destroyed and restarted do the following:
In your AndroidManifest.xml file go to the Application tab (Assuming you are in Eclipse, Manual programmers can still use this info, but will need to work out the corresponding xml), then under Application Nodes select the Activity you want to stop the rotations on, on the right hand side under “Attributes for
(Activity)” scroll down to Screen Orientation and set it to portrait or landscape. Then in the same section set config changes to “orientation|keyboardHidden”
Now back in your class add the following function and you’ll be good to go.
// Handle Screen Orientation (Stop Activity being killed and re-started) @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
Orig. Photo: https://flic.kr/p/nxzmKB
Found an issue?
All my posts are available to edit on GitHub, any fix is greatly appreciated!
