SimpleOrientationSensor returning Null

跟風遠走 提交于 2019-12-13 15:12:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/12853799/simpleorientationsensor-returning-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!