Another question:
android:screenOrientation="portrait" locks the screen orientation,
that's fine.
But it is possible to do the same in Activity source code ? (i.e.
removing the screenOrientation in AndroidManifest.xml).

I've tried the following code to keep the initial orientation but it
fails.

    private int initialOrientation =
Configuration.ORIENTATION_UNDEFINED;

    public void onCreate(Bundle savedInstanceState) {
        initialOrientation = getResources().getConfiguration
().orientation;
        ...
    }

    public void onConfigurationChanged(Configuration newConfig)
    {
        super.onConfigurationChanged(newConfig);
        setRequestedOrientation(initialOrientation);
    }

I've also tried with:
initialOrientation = getResources().getConfiguration().orientation;
initialOrientation = getRequestedOrientation();
initialOrientation = getWindow().getWindowManager().getDefaultDisplay
().getOrientation();


Thanks for the help.

On Aug 27, 9:54 pm, "Mark Murphy" <[email protected]> wrote:
> > I want my Activity to be always in portrait mode and I do NOT want the
> > onDestroy() method to be called.
> > There are some interesting articles about that at:
> >http://www.androidguys.com/2008/11/24/rotational-forces-part-four/
>
> > The solution seems to be:
> > In AndroidManifest.xml:
> >         <activity android:name=".MyActivity"
> >                      android:screenOrientation="portrait"
> >                      android:configChanges="keyboardHidden|orientation">
>
> > In Activity code:
> >     public void onConfigurationChanged(Configuration newConfig)
> >     {
> >            super.onConfigurationChanged(newConfig);
> >     }
>
> > I've tried it and it seems to work. Is there any other alternative or
> > is it the correct solution?
>
> Well, I think it's the correct solution. But, then again, I'm biased in
> favor of the author of that fine, upstanding blog post.
>
> ;-)
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
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