Thanks to a clever colleague here who suggested this.

Since sub-activities inherit any android:screenOrientation set on 
their launching parent in the manifest, if you lock the parent one 
way but want the user to be able to control the orientation of the 
child, you need an explicit constant for that. Lo! and behold! 
ActivityInfo has one, "user" -- so:

android:screenOrientation="user"

So "portrait," "landscape," "user," and "sensor" give pretty good control

I also see "nosensor" -- which I assume you need if you have 
previously set a parent to "sensor."  ? or?

Finally, there is "behind" -- does anyone know what a "behind 
orientation" would be" ?

-- Ward

====================

Okay, I think I know the answer as to what can cause an activity not to rotate.

Every activity I wanted to rotate was started with 
startActivityForResult() (i.e. it was a sub-activity). It appears 
sub-activities "inherit" the "android:screenOrientation" of their 
parent in the manifest.

In my case, I have portrait main screens, launching landscape 
sub-activities that contain forms for keyboard entry. If I set

android:screenOrientation="portrait"

on the main screen, the sub-activities will not rotate, unless I 
_explicitly_ add android:screenOrientation="landscape" to them. Which 
is fine, except they start out rotated, which is not necessarily what 
a user expects.

I suppose I could launch my data entry screens as first-class 
activities (using startActivity() instead of 
startActivityForResult()) and pass the results back out-of-band and 
manually restart the parent, but it sure isn't as pretty as using the 
built-in result machinery.

(Or, yes, I could become more "one" with Android and do two sets of 
layouts and put the user in absolute control, but that's a lot of 
work and I am so very lazy...)

-- Ward

====================

Hello All:

I asked this before and did not get an answer, so let me try again, simpler:

On the G1...

What can cause an activity to NOT rotate to landscape when the phone 
is opened? (I want it to rotate.)

No android:screenOrientation is set, and the activity is destroyed 
and recreated, but the new layout is still portrait.

Thanks

-- Ward

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to