Search code examples
cordovaevent-handlingintel-xdk

Intel XDK/Cordova onDeviceReady event does not fire


First I want to say that all the things work in the emulators, but when I build it and test it on a device they don't.

I wanted to set my orientation to landscape, so I followed the examples with:

document.addEventListener("intel.xdk.device.ready", onDeviceReady, false);               
function onDeviceReady(){
    intel.xdk.device.setRotateOrientation('landscape');
    intel.xdk.device.hideSplashScreen();   
}  

When I use it in "Test" mode, push the files on the server and then download the app from the cloud it works fine.

But when I build the app using Build-> Clicking Build for android from the "Cordova 3.X Hybrid Mobile App Platforms" menu, then download it and install it, it does not work.

You could say that I could build the app from the "Legacy Hybrid Mobile App Platforms" menu and then in the "Assets" menu to choose landscape. Yes that works, but I want also to use hideStatusBar() which also requires the onDeviceReady event to fire.

I'm testing it on Galaxy S2 with Android 4.1.2 and LG G2 with Android 4.4.2.

Also, I started a new project with a template and there are these lines:

// Listen to deviceready event which is fired when Cordova plugins are ready
document.addEventListener('deviceready', function() {
    // Call splashscreen API to hide the splash.
    navigator.splashscreen.hide();
});

But they also don't work.

It seems like the deviceReady event does not fire at all. Any idea what could be the problem or suggestions for workarounds? I just want the app to be in landscape and the status bar to be hidden. I don't need anything else from the XDK.

PS: If requested, I can post the index.html and other code.


Solution

  • Ok the problem was indeed in the enabling the plug- ins. It turned out I have to enable both "Device" plug- ins in "Included plug- ins menu" and also in the "Featured and Custom Cordova plug- ins". (right next to it).