OrientationLock - Android PhoneGap/Cordova Plugin for locking/unlocking the screen orientation from JS
From your JavaScript code call
window.plugins.OrientationLock.unlock()to unlock orientation,
window.plugins.OrientationLock.lock("portrait") or window.plugins.OrientationLock.lock("landscape")
to lock your screen to the specified orientation.
To start your PhoneGap/Cordova application pre-locked place
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
in the onCreate() of your DroidGap activity.
Once unlocked, you can track orientation changes with the regular 'orientationchange' event:
window.addEventListener("orientationchange", dojo.hitch(this, function() {
alert(window.orientation);
}, false);
Using this plugin requires Android PhoneGap.
To enable it..
- Put the orientationLock.js in the www/ directory of your PhoneGap project and reference it from your HTML.
- Put the OrientationLock.java in src/com/phonegap/plugins/ and add the following line in your res/xml/config.xml:
``