public class

Sensor

extends Object
java.lang.Object
   ↳ com.neomades.io.sensor.Sensor
Known Direct Subclasses

Class Overview

Class representing a sensor. Use a getter from the SensorManager to get back a sensor.

Summary

Constants
int PERIOD_FASTEST Gets sensor data as fast as possible.
int PERIOD_GAME Rate suitable for games.
int PERIOD_LOW Rate suitable for screen orientation changes.
int PERIOD_NORMAL Rate suitable for the user interface (Default).
int TYPE_ACCELEROMETER A constant describing an accelerometer sensor type.
int TYPE_GYROSCOPE A constant describing a gyroscope sensor type.
int TYPE_MAGNETOMETER A constant describing a magnetometer sensor type.
Protected Constructors
Sensor()
Sensor constructor.
Public Methods
int getType()
Gets the constant type corresponding to the Sensor.
boolean isActive()
Indicates whether sensor updates are currently happening.
void setListener(SensorListener listener)
Sets the listener allowing to receive notifications from the Sensor when sensor values have changed.
void start(int period)
Starts data acquisition from the sensor.
void stop()
Stops data acquisition from the sensor.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int PERIOD_FASTEST

Gets sensor data as fast as possible.

Constant Value: -4 (0xfffffffc)

public static final int PERIOD_GAME

Rate suitable for games.

Constant Value: -3 (0xfffffffd)

public static final int PERIOD_LOW

Rate suitable for screen orientation changes.

Constant Value: -1 (0xffffffff)

public static final int PERIOD_NORMAL

Rate suitable for the user interface (Default).

Constant Value: -2 (0xfffffffe)

public static final int TYPE_ACCELEROMETER

A constant describing an accelerometer sensor type.

Constant Value: 1 (0x00000001)

public static final int TYPE_GYROSCOPE

A constant describing a gyroscope sensor type.

Constant Value: 4 (0x00000004)

public static final int TYPE_MAGNETOMETER

A constant describing a magnetometer sensor type.

Constant Value: 5 (0x00000005)

Protected Constructors

protected Sensor ()

Sensor constructor. Called from the SensorManager.

Public Methods

public int getType ()

Gets the constant type corresponding to the Sensor.

Returns
  • the constant type corresponding to the Sensor
See Also

public boolean isActive ()

Indicates whether sensor updates are currently happening.

Returns
  • true if the Sensor is currently used

public void setListener (SensorListener listener)

Sets the listener allowing to receive notifications from the Sensor when sensor values have changed.

See Also

public void start (int period)

Starts data acquisition from the sensor.

Becarefull when you give the speed rate as a parameter. For some devices the speed rate could be to hight compared to the performance of the embedded sensor leading to fatal error.

Parameters
period is the rate chosen for data's recording

public void stop ()

Stops data acquisition from the sensor.