This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Mobile

Debugging Mobile Apps with HTML5 and Intel XDK

Using the Intel XDK IDE to debug an app from an iPad, an iPhone, Android, and Windows Phone devices.

In the first article in this two-part series on developing mobile apps with HTML5 and the Intel XDK, I explained how to create an HTML5 hybrid app from scratch that uses Intel App Framework and Apache Cordova. In this article, I explain how to debug a more complex app with the tools included in the IDE and the on-device debugging feature.

Making REST API Calls

In the previous article, our sample app uses the accelerometer available on various mobile devices to control the movement of a robot device (an Internet of Things project). The following lines show the JavaScript code for a very simple Node.js REST API that you can run in your environment, so you can see how to debug an Intel XDK project that consumes a REST API. If you don't work with Node.js, you will need to install it in order to run the example. Start Node.js, paste in the code, and the server will be listening at port 1337.

The same Cross-Origin Resource Sharing (CORS) restrictions that apply to Web-based HTML5 apps also apply to hybrid apps that run in a webview. Thus, I've added the necessary data in the response header.

Obviously, you won't be able to use localhost to access the REST API as you would in your local Web browser. So, it's necessary to use the IP address for your developer computer (on which you're running Node.js and where you started the previously shown code). I'll use 192.168.2.6 in my examples, but you should replace the IP address with the appropriate address for your computer.

Once you start running the code in Node.js, you can use a Web browser, Telerik Fiddler, or the curl utility to compose and send a GET request to your computer's IP address and port 1337, adding /move and different values for the x and y parameters. The following lines show four curl commands with possible combinations of values for the x and y parameters that the app will send:

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!