Cordova Android Sensor Listeners Plugin
This plugin gives easy access to every available Android's sensors.
Install
cordova plugin add https://github.com/QuentinRoy/cordova-plugin-android-sensor-listeners.git
API: sensors
- sensors :
object
undefined
sensors.addSensorListener(sensorType, samplingPeriod, listener, [callback]) ⇒ Add a sensor listener.
Kind: static method of sensors
Param | Type | Description |
---|---|---|
sensorType | string |
The sensor type's constant name (as defined by Android's Sensor, but without the prefix "TYPE_" ). |
samplingPeriod | string |
The sampling period's constant name (as accepted by SensorManager#registerListener, but without the prefix "SENSOR_DELAY_" ). |
listener | sensorEventListener |
The listener to register. |
[callback] | errorFirstCallback |
A node-style callback to be called upon success or failure of the operation. |
Example
{ console;} sensors;
undefined
sensors.removeSensorListener(sensorType, samplingPeriod, listener, [callback]) ⇒ Remove a sensor listener.
Kind: static method of sensors
Param | Type | Description |
---|---|---|
sensorType | string |
The type of the sensor as registered when the listener was added (see addSensorListener). |
samplingPeriod | string |
The sampling period as registered when the listener was added (see addSensorListener). |
listener | sensorEventListener |
The listener to remove. |
[callback] | errorFirstCallback |
A node-style callback to be called upon success or failure of the operation. |
Example
sensors;
Object
SensorEvent : Event emitted from sensors.
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
sensor | string |
The type of sensor that is listened to. |
sampling | string |
The sampling period the sensor is listened to by the receiving event listener. |
timeStamp | int |
The time the event was emitted. |
values | Array.<float> |
The sensor values. |
function
errorFirstCallback : This callback is used to get responses from async calls. It complies with nodeJS callback style.
Kind: global typedef
Param | Type | Description |
---|---|---|
[err] | * |
the error or undefined if everything went fine |
data | * |
the response or the called function |
function
sensorEventListener : This listener is used to receive events from sensors.
Kind: global typedef
Param | Type | Description |
---|---|---|
evt | SensorEvent |
the event emitted by one of the sensor |