Home » Latest Technology » Intel HTML5 Tools for developing mobile applications

Intel HTML5 Tools for developing mobile applications



December 27, 2013, 5:14 IST

Team Digit

Intel HTML5 Tools for developing mobile applications

HTML5 is the new HTML standard. Recently, Intel Corporation announced a set of HTML5 Tools for developing mobile applications. This paper shows you how to port an Apple iOS* accelerometer app to HTML5 using these tools. Please note: Auto-generated code created by the Intel XDK may contain code licensed under one or more of the licenses detailed in Appendix A of this document. Please refer to the Intel XDK output for details on which libraries are used to enable your application.

Intel HTML5 App Porter Tool

The first thing we’ll do is take an iOS accelerometer app and convert the Objective-C*source code to HTML5. We’ll do this using the Intel® HTML5 App Porter Tool and the source code found here: [iOS_source.zip] (Note: IOS_source sample code is provided under the Intel Sample Software License detailed in Appendix B).You can download the Intel HTML5 App Porter Tool from the Tools tab here: http://software.intel.com/en-us/html5. After filling in and submitting the form with your e-mail address, you will get links for downloading this tool. The instructions on how to use this tool can be found on this site: http://software.intel.com/en-us/articles/tutorial-creating-an-html5-app-from-a-native-ios-project-with-intel-html5-app-porter-tool

When you are finished performing all the steps, you will get HTML5 source code.

Intel XDK

You can open the HTML5 code in any IDE. Intel offers you a convenient tool for developing HTML5 applications: Intel XDK – Cross platform development kit (http://html5dev-software.intel.com/). With Intel XDK, developers can write a single source code for deployment on many devices. What is particularly good is it is not necessary to install it on your computer. You can install it as an extension for Google Chrome*. If you use another browser, you have to download a JavaScript* file and run it. Sometimes it’s necessary to update Java*.

After installing Intel XDK, you will see the main window:

If you want to port existing code, press the big “Start new” button.

If you’re creating a new project, enter the Project Name and check “Create your own from scratch,” as shown in the screen shot below.

Check “Use a blank project.” Wait a bit, and you will see the message “Application Created Successfully!”

Click “Open project folder.”

Remove all files from this folder and copy the ported files. We haven’t quite ported the accelerometer app yet. We still have to write an interface for it. It is possible to remove the hooks created by the Intel HTML5 App Porter Tool. Remove these files:

  • todo_api_application__uiaccelerometerdelegate.js
  • todo_api_application_uiacceleration.js
  • todo_api_application_uiaccelerometer.js
  • todo_api_js_c_global.js

To update the project in Intel XDK, go to the editor window in the Windows emulator.

Open the index.html file and remove the lines left from the included files.

Open the todo_api_application_appdelegate.js file and implement the unmapped “window” property of the delegate.

01 application.AppDelegate.prototype.setWindow = function(arg1)
02     // ================================================================
04     // line(17): C:WorkBloggingechuraevAccelerometerAccelerometerAppDelegate.m
05     //    In scope: AppDelegate.application_didFinishLaunchingWithOptions
06     //    Actual arguments types: [*js.APT.View]
07     //    Expected return type: [unknown type]
11         // TODO remove exception handling when implementing this method
12        // throw "Not implemented function: application.AppDelegate.setWindow";
17 application.AppDelegate.prototype.window = function()
18     // ================================================================
20     // line(20): C:WorkBloggingechuraevAccelerometerAccelerometerAppDelegate.m
21     //    In scope: AppDelegate.application_didFinishLaunchingWithOptions
22     //    Actual arguments types: none
23     //    Expected return type: [unknown type]
25     // line(21): C:WorkBloggingechuraevAccelerometerAccelerometerAppDelegate.m
26     //    In scope: AppDelegate.application_didFinishLaunchingWithOptions
27     //    Actual arguments types: none
28     //    Expected return type: [unknown type]
32         // TODO remove exception handling when implementing this method
33        // throw "Not implemented function: application.AppDelegate.window";

Open the viewcontroller.js file. Remove all the functions used for working with the accelerometer in the old iOS app. In the end we get this file:

01 APT.createNamespace("application");
03 document.addEventListener("appMobi.device.ready",onDeviceReady,false);
05 APT.ViewController = Class.$define("APT.ViewController");
07 application.ViewController = Class.$define("application.ViewController", APT.ViewController,
08     __init__: function()
09         this.$super();

In the ViewController_View_774585933.css file, we have to change styles of element colors from black to white to be readable on the black background: color: rgba(0,0,0,1); to color: rgba(256,256,256,1);. As a result we get:

04     color: rgba(256,256,256,1);
06     position: absolute;
07     text-align: left;
15     color: rgba(256,256,256,1);
17     position: absolute;
18     text-align: left;
26     color: rgba(256,256,256,1);
28     position: absolute;
29     text-align: left;
37     color: rgba(256,256,256,1);
39     position: absolute;
40     text-align: left;
48     color: rgba(256,256,256,1);
50     position: absolute;
51     text-align: left;
59     color: rgba(256,256,256,1);
61     position: absolute;
62     text-align: left;
70     color: rgba(256,256,256,1);
72     position: absolute;
73     text-align: left;
81     height: 548px;
82     position: absolute;

After updating the emulator window, you see:

To code the accelerometer functions, we need to use the appMobi JavaScript Library. Documentation for this library can be found here. It’s installed when you download Intel XDK.

Open the index.html file and add this line into the list of scripts:

<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/appmobi.js"></script>

Open the ViewController_View_774585933.html file. We have to rename fields to more logical names from:

1 <div data-apt-class="Label" id="Label_705687206">0</div>
2 <div data-apt-class="Label" id="Label_782673145">0</div>
3 <div data-apt-class="Label" id="Label_1067317462">0</div>


1 <div data-apt-class="Label" id="accel_x">0</div>
2 <div data-apt-class="Label" id="accel_y">0</div>
3 <div data-apt-class="Label" id="accel_z">0</div>

The same should be done in the ViewController_View_774585933.css file, where we have to rename the style names.

Open the viewcontroller.js file and write some functions for using the accelerometer.

02     document.getElementById('accel_x').innerHTML = a.x;
03     document.getElementById('accel_y').innerHTML = a.y;
04     document.getElementById('accel_z').innerHTML = a.z;
07 var watchAccel = function ()
09     opt.frequency = 5;
10     timer = AppMobi.accelerometer.watchAcceleration(suc, opt);
13 function onDeviceReady()
16 document.addEventListener("appMobi.device.ready",onDeviceReady,false);

Update the project, and you can see it on the emulator window:

You can see how the accelerometer works on Intel XDK using the “ACCELEROMETER” panel:

The application will look like this:

The complete application source code can be found here.

Nokia presents idea to app contest: Nokia Lumia 920, Nokia Lumia 820, reward points to be won… Come Get Yours