Software Archive
Read-only legacy content
17060 Discussions

intel.xdk.device.* API calls causing app to hang in App Preview

Daniel_B_3
Beginner
534 Views

Hi there,

The app works fine when I run it in debug, but when I run it via Intel App Preview on my device, the app hangs and fails to launch

            document.addEventListener("deviceready", onDeviceReady, false);
            function onDeviceReady() {
                alert("start1");
                
                $.feat.nativeTouchScroll = false;
                
                intel.xdk.device.setRotateOrientation("portrait");
                
                alert("start2");
                
                setTimeout(function () {
                    $.ui.launch();
                }, 50);
            }

"start2" is never displayed. If I remove the orientation line, it is displayed.

Same issue occurs for intel.xdk.cache.getCookie();

What's going on? Thanks.

0 Kudos
2 Replies
Barry_Johnson
New Contributor I
534 Views

Question: does it hang or does it fail? An exception thrown by the line would also stop execution. You might wrap it in a try/catch and see what isn't defined, as I bet that is the issue. I know I wrote a bunch of defensive code around this in the startup sequence, and it's one of the reasons I try to just use base Cordova APIs over XDK add-ons if at all possible.

You might also check if you have the same problem if you wait for "intel.xdk.device.ready" rather than Cordova's deviceready event or even if you wrapped the content of your onDeviceReady into a timeout pushed out 500-1000 ms.

0 Kudos
PaulF_IntelCorp
Employee
533 Views

See the "Standard HTML5+Cordova" blank template for a better way to detect the ready events on a variety of platforms. There is a file in there named init-dev.js in the xdk directory that generates a custom event named app.Ready. If you wait on that event you'll get a much more reliable ready event that works on all platforms.

Also, be sure you've included the required plugins. See this page for a list of the plugins and their methods and properties: https://software.intel.com/en-us/xdk/docs/intel-xdk-api-cordova-plugin-methods-properties-events

Additionally, if you are running on the Legacy build platform you need to insure that you have all three of these files in your index.html file:

    <script src="intelxdk.js"></script>         <!-- phantom library, needed for XDK api calls -->
    <script src="cordova.js"></script>          <!-- phantom library, needed for Cordova api calls -->
    <script src="xhr.js"></script>              <!-- phantom library, needed for XDK CORS -->

 

0 Kudos
Reply