Share via


SensorManager.RequestTriggerSensor(TriggerEventListener, Sensor) Method

Definition

Requests receiving trigger events for a trigger sensor.

[Android.Runtime.Register("requestTriggerSensor", "(Landroid/hardware/TriggerEventListener;Landroid/hardware/Sensor;)Z", "GetRequestTriggerSensor_Landroid_hardware_TriggerEventListener_Landroid_hardware_Sensor_Handler")]
public virtual bool RequestTriggerSensor (Android.Hardware.TriggerEventListener? listener, Android.Hardware.Sensor? sensor);
[<Android.Runtime.Register("requestTriggerSensor", "(Landroid/hardware/TriggerEventListener;Landroid/hardware/Sensor;)Z", "GetRequestTriggerSensor_Landroid_hardware_TriggerEventListener_Landroid_hardware_Sensor_Handler")>]
abstract member RequestTriggerSensor : Android.Hardware.TriggerEventListener * Android.Hardware.Sensor -> bool
override this.RequestTriggerSensor : Android.Hardware.TriggerEventListener * Android.Hardware.Sensor -> bool

Parameters

listener
TriggerEventListener

The listener on which the TriggerEventListener#onTrigger(TriggerEvent) will be delivered.

sensor
Sensor

The sensor to be enabled.

Returns

true if the sensor was successfully enabled.

Attributes

Exceptions

when sensor is null or not a trigger sensor.

Remarks

Requests receiving trigger events for a trigger sensor.

When the sensor detects a trigger event condition, such as significant motion in the case of the Sensor#TYPE_SIGNIFICANT_MOTION, the provided trigger listener will be invoked once and then its request to receive trigger events will be canceled. To continue receiving trigger events, the application must request to receive trigger events again.

Java documentation for android.hardware.SensorManager.requestTriggerSensor(android.hardware.TriggerEventListener, android.hardware.Sensor).

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.

Applies to