views:

142

answers:

2

I have an app that works only in portrait mode, and I have made the changes in my manifest file for every activity the orientation to be portrait. But when I rotate the device, the activity recreates again. How to not destroy the activity?

+3  A: 

add

android:configChanges="orientation"

to your Activity in AndroidManifest.xml. This way your Activity wont be restarted automatically. See the documentation for more infos

flurin
The activity is restarted again.I don't know what's the point of doing all the stuff that has to be done when the activity rotates, even if it is not rotating virtually. Is there a way to disable that messages that the sensor sends to the OS about the rotation, or something like that, to fix this problem from its root?
on what device are you programming? remember, that for example sliding out the keyboard could also restart your activity... (if that's the reason set confChanges to "keyboard|keyboardHidden|orientation")
flurin
A: 

Look at this code in Floating Image. It has the most interesting way of handling screen rotation ever. http://code.google.com/p/floatingimage/source/browse/#svn/trunk/floatingimage/src/dk/nindroid/rss/orientation

androidworkz