Intel® XDK Basic Hybrid App Sample

The source code for this sample can be found here: https://github.com/gomobile/sample-basichybrid or download the Intel® XDK to check out all the HTML5 Samples.

Purpose

The Basic Hybrid App sample is intended to demonstrate the basics of creating a hybrid mobile app that relies on the JavaScript bridge library to provide an API to native features of the device it runs on. It shows how to react to the JavaScript event that indicates that it is ready to go as well as how to manage the splash screen that hides the HTML as it loads into the browser control at startup.

Source Code

There are a few salient parts of the source code of this sample that are of note. First of all, the JavaScript bridge library to provide the API to native features.

Secondly, the event that is fired indicating that the JavaScript bridge library is loaded successfully and the native API bridge code is available.

Next, the event listener fires an event handler that indicates that the JavaScript bridge library is loaded will ultimately turn off the splash screen that hides the Web view as the app loads. That line of code looks like this.

Finally, once the application is started the buttons on the screen will activate a variety of native features using the JavaScript bridge API.

Easter Eggs

There are three JavaScript libraries that may be uncommented that add additional functionality to the sample application. One can be turned on to add a camera feature, one will listen to the accelerometer for someone shaking the device, and another will display the location sensed from the device. The code to turn on these hidden features look like this.

Testing

This sample application has been tested on a variety of iOS and Android smartphones.

For more complete information about compiler optimizations, see our Optimization Notice.