Using the Accelerometer Class

Accelerometer, like the other sensor types, uses an event-based model for monitoring changes to sensor readings.

Note

Accelerometer contains a ReadingChanged event, which should not be used because it is a remnant of the first release of the Windows Phone OS and has been deprecated as of the 7.1 release of the SDK.

The event to use is the base class SensorBase event: CurrentValueChanged. Subscribing to the event can be done as follows:

var accelerometer = new Accelerometer();accelerometer.CurrentValueChanged += HandleSensorValueChanged;accelerometer.Start();

When the CurrentValueChanged event is raised, the event handler receives a SensorReadingEventArgs<AccelerometerReading> object, ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.