haha yes
haha yes

Reputation: 13

I cannot lock Cordova screen mode using screen orientation plugin

I can't lock my screen mode to portrait using the screen orientation plugin in Cordova android Every time I tried it allowed me to rotate to landscape mode

I tried to use this code but it doesnt work

            function onDeviceReady() {
                screen.orientation.lock('portrait-primary')
            }

            document.addEventListener('deviceready', function() {
                onDeviceReady()
            })

I expect it to lock the mode to portrait mode but it doesnt work

Upvotes: 1

Views: 761

Answers (2)

Mister_CK
Mister_CK

Reputation: 1063

In our app we do it like this:

  window.screen.orientation.lock('portrait-primary');

So I think your problem is that you are not calling it on the window. screen is a property in window, you cannot call on it directly, I think.

Upvotes: 0

Eric
Eric

Reputation: 10626

Any reason why you are using a plugin for this? You can simply set

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

Upvotes: 1

Related Questions