LightSensor.GetDefault LightSensor.GetDefault LightSensor.GetDefault LightSensor.GetDefault LightSensor.GetDefault Method

Definition

Returns the default ambient-light sensor.

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

Returns

The default ambient-light sensor or null if no integrated light sensors are found.

Remarks

This method only returns values for a light sensor 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 light sensor.

_sensor = LightSensor.GetDefault();

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

lightSensor = Windows.Devices.Sensors.LightSensor.getDefault();