WP8Dev– How to identify the sensors supported on your Windows Phone

This post will give you an  overview on how to identify the sensors supported on your Windows Phone. As a developer when you are developing for Windows Phone – and your application would need to interact with certain sensors in windows phone to achieve a certain functionality, you would need to verify whether the sensors are supported in  targeted devices.

Windows Phone 8 platform has support for the following sensors

  • Motion sensor  
  • Accelerometer
  • Compass
  • Gyroscope

You can access these API’s through the below namespace:

Microsoft.Devices.Sensors

You can check for any of the sensor support through “IsSupported” boolean property of the class

  • Motion sensor   [ Microsoft.Devices.Sensors.Motion ]
  • Accelerometer  [ Microsoft.Devices.Sensors.Accelerometer ]
  • Compass [ Microsoft.Devices.Sensors.Compass ]
  • Gyroscope  [ Microsoft.Devices.Sensors.Gyroscope ]

Here is the sample code block:

Note: Only Accelerometer is supported in Windows Phone 8 emulator. To test remaining capabilities, you would need to deploy the application on a real Windows Phone device.

Other times, you're doing some piece of work and suddenly you get feedback that tells you that you have touched something that is very alive in the cosmos. Share your feedback on this blog, it will help me improve it a lot..