Compass.GetDefault Compass.GetDefault Compass.GetDefault Compass.GetDefault Compass.GetDefault Method

Definition

Returns the default compass.

public : static Compass GetDefault()
static Compass GetDefault() const;
public static Compass GetDefault()
Public Shared Function GetDefault() As Compass
var compass = Windows.Devices.Sensors.Compass.getDefault();

Returns

The default compass or null if no integrated compasses are found.

Remarks

This method only returns values for a compass that has been integrated into the computer by the manufacturer. A null value will be returned if the specified sensor is not available in the system.

When a system is in Connected Standby, a call to the GetDefault method will return immediately with a null result.

The following example demonstrates how a UWP app built with XAML and C# used this method to establish a connection to the default compass.

_compass = Compass.GetDefault();

The following example demonstrates how a UWP app built for Windows using JavaScript used this method to establish a connection to the default compass.

compass = Windows.Devices.Sensors.Compass.getDefault();