admin管理员组

文章数量:1392081

I'm using the cordova-plugin-screen-orientation plugin and have followed all of the instructions I can find for locking orientation and nothing is working. I'm running the application in Android Studio emulator and my Pixel phone.

In config.xml I have no mention of orientation.

In index.js I have

function onDeviceReady() {
    //not great but it's good enough for me
    var isPhone = screen.height < 800 || screen.width < 800;
    if (isPhone == false) {
        // Lock to landscape for tablets
        screen.orientation.lock('landscape-primary');
    } else {
        // Lock to portrait for phones
        screen.orientation.lock('portrait-primary');
    }
}
document.addEventListener('deviceready', onDeviceReady);

I also tried placing the JS in the HTML at the bottom. What am I doing wrong?

本文标签: androidSet orientation to landscape for tabletsportrait for phonesStack Overflow