Quantcast
Channel: Android*
Viewing all articles
Browse latest Browse all 531

Intel XDK Simple Accelerometer Sample

$
0
0

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

Purpose

The accelerometer demonstration is a very simple implementation of how the intel.xdk JavaScript Bridge Library can be used to read a device's accelerometer data in a hybrid app.

Source Code

The initial event thrown when the intel.xdk library loads calls an event handler that includes this command. This command makes the device start reading accelerometer data and throwing JavaScript events to relay the results back to the HTML5.

This function handles the events thrown by the device relaying accelerometer information back to the HTML5. This function uses a simple CSS3 transformation to rotate the arrow image to align it with the current accelerometer reading.

Use the Accelerometer portion of the XDK to test this sample application in the simulator.

Testing

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

Limitations

On an iOS device, the operating system will flip any application if the device is held upside down. While this could be helpful for any user who might not know how to hold their device properly, it can be frustrating for an accelerometer demo app such as this one.


Viewing all articles
Browse latest Browse all 531


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>