views:

142

answers:

2

Looked at other posts but, haven't seen the answer I'm looking for...

I have two layouts: layout-port and layout-land.
If I run the app with emulator or device, either vertically or horizontally, the app runs fine with the correct layouts.

However, if I rotate either the emulator or device, the app exits. There's no crashing, perse', it just exits.

I have other app's with similarly defined layouts that work fine without any orientation handling in the manifest. I'm not concerned about persisting data.

The main differences between the one's that work and this one are (this one has):
* Menus with sub-menus
* Dialog screens (not the android dialog widget)
* Tab widget

All of the above items work in their respective layouts (port and land), the app just exits when rotating the emulator or device and I need to restart the app.

Any recommendations? Thanks alt text

The Manifest:

(deleted)

A: 

Did you try to add android:configChanges="orientation" to your activity declaration in the manifest? Normally when the configuration changes, the activity is shut down and restarted. Adding this "flag" prevents this and calls the onConfigurationChanged() method instead.

Juri
Thanks. Yes, I tried it several times, including placing it in each activity tag. And, as mentioned, also tried using the sensor tag. That's what's so odd about it. The configChanges has always seemed to work in my other app's. The only other odd thing about what I see from the logCat is the duplicate finish request in the warning.
headscratch
Added: I locked in the portrait orientation, ran the app in landscape then, toggled to portrait and noticed that just before the app exited, the layout displayed. This almost suggest is is related to the duplicate finish cited in the logcat. My code, however only calls finish in the different activities, not in onCreate. Puzzling...
headscratch
+2  A: 

If you use the above code, make one modification:

android:configChanges="keyboard|keyboardHidden|orientation"

using only "orientation" will handle orientation changes driven by accelerometers and such, but on devices with a physical keyboard and a slide-out screen the activity will still be shut down and restarted any time a user slides open their keyboard.

David Perry
Thanks! That sort of did the trick! It stopped it from dying but, it retains the portrait layout and never changes to landscape. Actually, I'll live with that for this app. I would like to know why adding the keyboard stuff took care of it (just orientation, as suggested by Juri, didn't). My device doesn't have a physical keyboard. I've never before needed to do that and I suspect it must have something to do with the app's menu/sub-menu's needing user keyed input.Thanks again!
headscratch
:D cool, I had the keyboard stuff in my activities, but removed it in my post since it didn't make sense for me :)
Juri