Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap Disable Screen Rotate On Single Page?

I am using PhoneGap, and am working with an Android web based app.

How do I disable screen rotation for only one page?

I have searched for this solution but all the solutions say to disable screen rotation in the AndroidManifest.xml file. However, this disables rotation for the whole app. I only need to disable rotation for one page.

Can this be done using PhoneGap / Javascript code? I am not using any Java code.

Thanks.

like image 791
nomaam Avatar asked Apr 28 '12 06:04

nomaam


3 Answers

You can simply remove the following tag or set it at 'portrait' in your config.xml file :

<preference name="orientation" value="portrait" />

For more informations, read the phonegap documentation :

https://build.phonegap.com/docs/config-xml

like image 111
bichehype Avatar answered Nov 16 '22 14:11

bichehype


I know this post is a few months old but there is a plugin for phonegap which can help you... It is a plugin that can lock or unlock screen orientation.

OrientationLock - Android PhoneGap

like image 27
MaramTech Avatar answered Nov 16 '22 14:11

MaramTech


This is simple way to lock rotation:

1/. Edit in config.xml file:

<preference name="orientation" value="portrait" />

2/. Put this code into Android Manifestxml file in:

<activity>
    ...
    android:screenOrientation="portrait"
    ...
</activity>
like image 2
Phong NGUYEN Avatar answered Nov 16 '22 14:11

Phong NGUYEN