Compartir a través de


SensorManager.GetDefaultSensor Method

Definition

Overloads

GetDefaultSensor(SensorType)

Use this method to get the default sensor for a given type.

GetDefaultSensor(SensorType, Boolean)

Return a Sensor with the given type and wakeUp properties.

GetDefaultSensor(SensorType)

Use this method to get the default sensor for a given type.

[Android.Runtime.Register("getDefaultSensor", "(I)Landroid/hardware/Sensor;", "GetGetDefaultSensor_IHandler")]
public virtual Android.Hardware.Sensor? GetDefaultSensor (Android.Hardware.SensorType type);
[<Android.Runtime.Register("getDefaultSensor", "(I)Landroid/hardware/Sensor;", "GetGetDefaultSensor_IHandler")>]
abstract member GetDefaultSensor : Android.Hardware.SensorType -> Android.Hardware.Sensor
override this.GetDefaultSensor : Android.Hardware.SensorType -> Android.Hardware.Sensor

Parameters

type
SensorType

of sensors requested

Returns

the default sensor matching the requested type if one exists and the application has the necessary permissions, or null otherwise.

Attributes

Remarks

Use this method to get the default sensor for a given type. Note that the returned sensor could be a composite sensor, and its data could be averaged or filtered. If you need to access the raw sensors use SensorManager#getSensorList(int) getSensorList.

Java documentation for android.hardware.SensorManager.getDefaultSensor(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

GetDefaultSensor(SensorType, Boolean)

Return a Sensor with the given type and wakeUp properties.

[Android.Runtime.Register("getDefaultSensor", "(IZ)Landroid/hardware/Sensor;", "GetGetDefaultSensor_IZHandler")]
public virtual Android.Hardware.Sensor? GetDefaultSensor (Android.Hardware.SensorType type, bool wakeUp);
[<Android.Runtime.Register("getDefaultSensor", "(IZ)Landroid/hardware/Sensor;", "GetGetDefaultSensor_IZHandler")>]
abstract member GetDefaultSensor : Android.Hardware.SensorType * bool -> Android.Hardware.Sensor
override this.GetDefaultSensor : Android.Hardware.SensorType * bool -> Android.Hardware.Sensor

Parameters

type
SensorType

type of sensor requested

wakeUp
Boolean

flag to indicate whether the Sensor is a wake-up or non wake-up sensor.

Returns

the default sensor matching the requested type and wakeUp properties if one exists and the application has the necessary permissions, or null otherwise.

Attributes

Remarks

Return a Sensor with the given type and wakeUp properties. If multiple sensors of this type exist, any one of them may be returned.

For example, <ul> <li>getDefaultSensor(Sensor#TYPE_ACCELEROMETER, true) returns a wake-up accelerometer sensor if it exists. </li> <li>getDefaultSensor(Sensor#TYPE_PROXIMITY, false) returns a non wake-up proximity sensor if it exists. </li> <li>getDefaultSensor(Sensor#TYPE_PROXIMITY, true) returns a wake-up proximity sensor which is the same as the Sensor returned by #getDefaultSensor(int). </li> </ul>

<p class="note"> Note: Sensors like Sensor#TYPE_PROXIMITY and Sensor#TYPE_SIGNIFICANT_MOTION are declared as wake-up sensors by default. </p>

Java documentation for android.hardware.SensorManager.getDefaultSensor(int, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to