If you'd like a quick tour of all the options for
setRequestedOrientation(), my app, SmartVolume Free, does this, and
lets you control what value to supply to setRequestedOrientation() in
a preference setting. (The default is to not set it at all, and use
the system's setting).

Of course, it's not hard to throw the code into your app, but this way
you can switch back and forth more quickly.

I'm still not clear on how the orientation is chosen for
ActivvityInfo.SCREEN_ORIENTATION_NOSENSOR. On my device (N1) it seems
to always come up in Portrait. I don't know if this is intended to be
"a suitable default for the device", or something else. It doesn't
appear to be "what orientation the device was in on start", which I
think would be more useful. I guess I'll go fill a documentation bug.

I put this in for a couple reasons. One is that my app is more usable
in portrait mode, but switching to portrait mode if you're using it in
landscape may not be desirable. Another is that before 2.1 update 1,
the launcher would crash (out of memory) if it was behind a window
that switched to landscape and you had too many apps...

On Apr 18, 1:27 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> Isaac Wagner wrote:
> > On Sun, Apr 18, 2010 at 3:25 PM, Justin Giles <jtgi...@gmail.com> wrote:
> >> Why would you want to allow them to set it in settings when Android handles
> >> the rotation automagically?  All you have to do is have a xml file in your
> >> "layout" directory, then for landscape have a xml file (with the same name)
> >> in your "layout-land" directory.  When in portrait mode Android looks to 
> >> the
> >> "layout" directory.  When the phone is flipped to its side for landscape,
> >> Android looks to the "layout-land" directory.
> >> Justin
>
> > <sigh> why is it that when I ask a simple question I get harassed?
>
> This discussion list gets a lot of people asking questions where they
> are barking up the wrong tree. It is commonplace to inquire about their
> rationale for barking up that tree and steer them in the direction of
> more common patterns. Sometimes, the barking is indeed up the correct
> tree, but that may not always be obvious from the question.
>
> If you consider that to be harassment, you may wish to choose a
> different means of getting Android developer support.
>
> > OK, since it appears I can't get a simple answer without a long
> > explanation.... My application is one such that the user moves their
> > phone around a lot.  During this movement I want to keep the
> > orientation constant -- I DON'T WANT ANDROID TO HANDLE THE ROTATION.
> > So, in my manifest I set the orientation to portrait to prevent
> > Android from mucking with the orientation.  However, I am now making
> > some additions and would like the user to be able to choose portrait
> > or landscape mode, but whatever they choose needs to stick.  Again, I
> > don't want Android to handle the rotation.  As the phone is moved
> > around I want whichever orientation they chose to stick.
>
> > Does that make sense?  Now, how do I do this?  How do I force the
> > orientation to my preference?
>
> You can try the combination of setRequestedOrientation() in onCreate()
> (and from the menu or wherever the user chooses their preference) and
> android:configChanges="keyboardHidden|orientation" in your manifest. I
> have not used setRequestedOrientation() personally.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in NYC: 30 April-2 May 2010:http://guruloft.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

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

Reply via email to