How to set a fixed (portrait or landscape) orientation in Android?

4,210 views
Skip to first unread message

Airbrone

unread,
Oct 14, 2009, 10:19:54 AM10/14/09
to phonegap
Hi there!

On this time I'm writing to ask if anyone knows how to set a fixed
orientation in phonegaps applications for Android.

I've read several messages talking about this topic for iPhone but
I've not found the way to do this in Android (neither surfing on the
web). All what I have found is a javascript function to detect the
orientation of the phone but what I need is to know how to set
landscape orientation for my app.

Can anyone help me, please?

Thank you!

Airbrone.

PanMan

unread,
Oct 15, 2009, 4:44:43 AM10/15/09
to phonegap
Sure. It's in the androidmanifest.xml
You can open this in eclipse, and set all options to fixed.
If needed I can share my manifest here.
Kind Regards,
PanMan.

Airbrone

unread,
Oct 15, 2009, 6:18:03 AM10/15/09
to phonegap
Thank you for your tip, Panman.

I have not found the place to set all values to fixed editing
androidmanifest.xml in Eclipse, as you suggested, but I have changed
in that file the line:

<activity android:name=".DroidGap"
android:label="@string/app_name"
android:screenOrientation="landscape" >

to :

<activity android:name=".DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden" >

and it works perfectly!

Best Regards,

David.

Airbrone

unread,
Oct 15, 2009, 6:20:09 AM10/15/09
to phonegap
Sorry, the change was just in the opposite way, I mean, I have changed
the line:

<activity android:name=".DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden" >

to:

<activity android:name=".DroidGap"
android:label="@string/app_name"
android:screenOrientation="landscape" >

Best Regards,

David.
Reply all
Reply to author
Forward
0 new messages