Hi,

  You can change the current orientation of the window by using the
WindowManager.LayoutParams class. This class provides the following flags:

int  
FLAG_ORIENTATION_DEFAULT<http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#FLAG_ORIENTATION_DEFAULT>
  Window flag: Force the display to the user's current orientation setting,
regardless of the windows behind it.  12288  0x00003000   int
FLAG_ORIENTATION_LANDSCAPE<http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#FLAG_ORIENTATION_LANDSCAPE>
  Window flag: The display must be in a landscape orientation when this
window is at the top.  8192  0x00002000   int
FLAG_ORIENTATION_PORTRAIT<http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#FLAG_ORIENTATION_PORTRAIT>
  Window flag: The display must be in a portrait orientation when this
window is at the top.  4096  0x00001000

Get your  current Activity's  Window object and set the flags above to
change orientation of the window:

   getWindow().setFlags(
                    WindowManager.LayoutParams.FLAG_ORIENTATION_PORTRAIT,
                    WindowManager.LayoutParams.FLAG_ORIENTATION_DEFAULT);
   or

   getWindow().setFlags(
                    WindowManager.LayoutParams.FLAG_ORIENTATION_LANDSCAPE,
                    WindowManager.LayoutParams.FLAG_ORIENTATION_DEFAULT);


When you change the orientation, it is a configuration change which will
cause your current activity to be *destroyed*, you may want to bypass
restarting
of your activity by setting
android:configChanges<http://code.google.com/android/reference/android/R.attr.html#configChanges>attribute
in its manifest as follows:

  <activity android:name=".OrientationTest" android:label="OrientationTest"
        android:configChanges="orientation">
            <intent-filter>
              ...
            </intent-filter>
   </activity>

More details on this are under the "Configuration Changes" section in the
link below:
http://code.google.com/android/reference/android/app/Activity.html

Thanks,
Megha



On Fri, Mar 28, 2008 at 1:03 PM, CJ <[EMAIL PROTECTED]> wrote:

>
> Hi, guys
> I saw this statement in the forum which was posted in Jan08
> *quote: The current SDK doesn't have complete support for
> orientations, and definitely not orientation switching while running.
> *
> First of all, is it still true?
> Also, can anybody give a reference?
> Thanks
> CJ
> >
>

--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to