Search code examples
c#windows-8microsoft-metro.net-4.5

SimpleOrientationSensor returning Null


I'm using SimpleOrientationSensor to get the screen orientation information in my application. I'm testing this application in Windows Simulator but I always get the sensor object's value as null.

This is what I'm doing:

SimpleOrientationSensor sensor;

sensor = SimpleOrientationSensor.GetDefault();
if (sensor != null)
{
     sensor.OrientationChanged += sensor_OrientationChanged;
}

I understand that SimpleOrientationSensor.GetDefault() will return null when there is no Sensor available. Should I tweak the Simulator to get the sensor information? Or does it even handle these changes?


Solution

  • According to this article the simulator doesn't support the SimpleOrientationSensor class.

    The Simulator doesn’t support the emulation of Orientation Sensor, and is only able to trigger a display orientation change.