O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

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

Adjusting the accelerometer sensor update interval

The getCurrentAcceleration method obtains data from the accelerometer at the time it was called - a single call to obtain a single response object. In this recipe, we'll build an application that allows us to set an interval to obtain a constant update from the accelerometer to detect continual movement from the device.

How to do it…

We will provide additional parameters to a new method available through the PhoneGap API to set the update interval:

  1. First, create a new PhoneGap project named accelupdate. Open Terminal or Command Prompt and run the following command:
    phonegap create accelupdate com.myapp.accelupdate accelupate
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:

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