Skip to content
 
 

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

OrientationLock - Android PhoneGap/Cordova Plugin for locking/unlocking the screen orientation from JS



Calling the plugin

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);

Adding the Plugin to your project

Using this plugin requires Android PhoneGap.

To enable it..

  1. Put the orientationLock.js in the www/ directory of your PhoneGap project and reference it from your HTML.
  2. Put the OrientationLock.java in src/com/phonegap/plugins/ and add the following line in your res/xml/config.xml:

``

About

A phonegap/cordova plugin for locking the orientation

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages