Microsoft.Devices.Sensors Namespace

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This namespace provides APIs to access the accelerometer and other sensors on the phone.

Capabilities

If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.

ID_CAP_SENSORS

Windows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone 8.

Classes

  Class Description
Accelerometer Provides Windows Phone applications access to the device’s accelerometer sensor.
AccelerometerFailedException The exception that may be thrown during a call to Start()()() or Stop()()(). The Message field describes the reason for the exception and the ErrorId field contains the error code from the underlying native code implementation of the accelerometer framework.
AccelerometerReadingEventArgs Provides data for ReadingChanged events.
CalibrationEventArgs Provides data for Calibrate and events.
Compass Provides Windows Phone applications access to the device’s compass sensor.
Gyroscope Provides Windows Phone applications access to the device’s gyroscope sensor.
Motion Provides Windows Phone applications information about the device’s orientation and motion.
SensorBase<(Of <(TSensorReading>)>) The base class for all Windows Phone sensor classes.
SensorFailedException Represents the exception that is thrown when a sensor operation fails.
SensorReadingEventArgs<(Of <(T>)>) Provides data for CurrentValueChanged events.

Structures

  Structure Description
AccelerometerReading Contains the acceleration and timestamp for an accelerometer reading, indicating the magnitude and direction of forces applied to the device.
AttitudeReading Contains information about the orientation of the device in space.
CompassReading Contains information about the magnetic field detected by the device’s compass sensor, which can be used to determine the orientation of the device relative to the Earth’s magnetic field.
GyroscopeReading Contains information about the rotation acceleration of the device.
MotionReading Contains information about the orientation and movement of the device.

Interfaces

  Interface Description
ISensorReading The interface that is implemented by all sensor reading classes.

Enumerations

  Enumeration Description
SensorState An enumeration of values for expressing the current state of the accelerometer. The state of a sensor can be obtained using its State property.