Community
cancel
Showing results for 
Search instead for 
Did you mean: 
99 Views

How can I set the orientation landscape

Hi

I have to show a barcode (code 128) to my users, it can not be qr, but this code does not fit on the screen, then when clicking on a link the screen should have a horizontal orientation, this using jQuery or Cordova, How can I do this?

Best Regards

Tags (2)
0 Kudos
5 Replies
99 Views

I found this

https://www.npmjs.com/package/cordova-plugin-screen-orientation

https://www.w3.org/TR/screen-orientation/

What script should I have loaded? cordova.js?

Also mentions "The Screen Orientation API", how can I load this api?

99 Views

Including the following

    <script src="cordova.js" id="xdkJScordova_"></script>

    <script src="js/app.js"></script>           <!-- for your event code, see README and file comments for details -->
    <script src="js/init-app.js"></script>      <!-- for your init code, see README and file comments for details -->
    <script src="xdk/init-dev.js"></script>     <!-- normalizes device and document ready events, see file for details -->
        <script type="text/javascript" charset="utf-8" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
 

I got it the following errer

Uncaught TypeError: undefined is not a function principal.js:280

I think I should include the Orientation Screen API, but how can I do it?

99 Views

a

 

 

 

99 Views

I successfully installed the plugin but I still have the same error

Uncaught TypeError: undefined is not a function principal.js:280

Other new errors

Uncaught module cordova-plugin-screen-orientation.screenorientation.android already defined 
Uncaught module cordova-plugin-screen-orientation.screenorientation already defined 

I am using

            screen.lockOrientation('landscape');

Then what am i doing wrong?

PaulF_IntelCorp
Employee
99 Views

Are you doing this testing in the Simulate tab, in App Preview (via Test tab) or on a real device using a built app? I think the screen orientation feature will do nothing in the Simulate tab. I believe it will work in App Preview.

This error message "Uncaught TypeError: undefined is not a function principal.js:280" indicates a problem in your code or in some library you've included as part of your code, it has nothing to do with Cordova or the XDK.

These error messages:

Uncaught module cordova-plugin-screen-orientation.screenorientation.android already defined 
Uncaught module cordova-plugin-screen-orientation.screenorientation already defined 

look like a typical message generated by the Simulate tab, which can be safely ignored. But if you are doing this in the Simulate tab you're not likely to see the orientation feature work. Try it on a real device.

BTW -- the jQuery folks have advised against using jQuery 3 in a Cordova app, it apparently does not work well with some device webviews. I recommend you use jQuery 2.

Reply