Using the Compass Sensor
The compass sensor is a required component of Windows Phone devices. In the first release of the Windows Phone OS (7.0), however, no API was provided for the compass, and some devices lacked the native drivers necessary to use the compass even when running the Windows Phone 7.5 OS (mango). If you are maintaining an app for a premango device, it is therefore important to verify that the compass is supported before attempting to use it. For this, the static Compass.IsSupported
property is used, as demonstrated in the CompassViewModel
class (see Listing 16.4). The Start
method of the CompassViewModel
oversees the creation of the Compass
instance.
The default value of the compass TimeBetweenUpdates
property is 25 milliseconds, ...
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.