O'Reilly logo

PhoneGap Essentials by Ivan Turkovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Device Motion plugin

The Device plugin provides access to information about the device's accelerometer data. The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current device orientation, in three dimensions along the x, y, and z axes.

Device Motion plugin is capturing accelerometer data at a specific snapshot in time. Values for the x, y, and z axes are expressed in m/s^2 and include the effect of gravity (9.81 m/s^2). For example, when the device is lying on top of the table and facing up, the x and y values are 0 and the z value is returning 9.81.

To install the plugin you need to run the following command:

phonegap plugin add cordova-plugin-device-motion

The Device Motion plugin has a few methods ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required