Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Compass.GetDefault | getDefault method

Returns the default compass.

Syntax


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

Parameters

This method has no parameters.

Return value

Type: Compass

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 Windows Store 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 Windows Store app built for Windows using JavaScript used this method to establish a connection to the default compass.


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


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Devices.Sensors
Windows::Devices::Sensors [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

None supported

Minimum supported phone

Windows Phone 8

Namespace

Windows.Devices.Sensors
Windows::Devices::Sensors [C++]

Metadata

Windows.winmd

See also

Compass

 

 

Show:
© 2015 Microsoft