Downloads
Intel® HTML5 Tools for developing mobile applications [PDF 821.98KB]
iOS Source Code [ZIP file 168 KB]
HTML5 Tools Result Source Code [ZIP file 86KB]
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
NOTICE: The current BETA program ended on Dec 31th, 2013. The Intel® HTML5 App Porter Tool – BETA is no longer available.
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) { |
17 |
application.AppDelegate.prototype.window = function () { |
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 () { |
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 ); |
15 |
color : rgba( 256 , 256 , 256 , 1 ); |
26 |
color : rgba( 256 , 256 , 256 , 1 ); |
37 |
color : rgba( 256 , 256 , 256 , 1 ); |
48 |
color : rgba( 256 , 256 , 256 , 1 ); |
59 |
color : rgba( 256 , 256 , 256 , 1 ); |
70 |
color : rgba( 256 , 256 , 256 , 1 ); |
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 > |
to:
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 () { |
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:
Related Links and Resources
To learn more about Intel tools for the Android developer, visit Intel® Developer Zone for Android.
The complete application source code can be found here.
Appendix A: Intel® XDK Code License Agreements
Appendix B: Intel Sample Source Code License Agreement
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
Copyright © 2013 Intel Corporation. All rights reserved.
*Other names and brands may be claimed as the property of others.