public class SensorStorage
extends java.lang.Object
Constructor and Description |
---|
SensorStorage() |
Modifier and Type | Method and Description |
---|---|
void |
clearSensorEvent()
Clear the HashMap to keep
SensorEvent objects. |
java.util.ArrayList<SensorHolder> |
getSensorHolders()
Generate an ArrayList of
SensorHolder objects as the
latest collection of SensorEvent object and timestamp. |
java.lang.String |
getSensorTypeName(int sensorType)
Each
Sensor object has its own name such like
"Goldfish 3-axis Accelerometer", but it's arbitrarily named by
the device vendor and thus difficult to handle programmatically. |
java.util.ArrayList<java.lang.String> |
getSensorTypeNames(java.util.ArrayList<java.lang.Integer> sensorTypes)
Generate an ArrayList of SensorTypeName which corresponds to
the given ArrayList of SensorType.
|
java.util.ArrayList<java.lang.Integer> |
getSensorTypes()
Available
Sensor objects on this device are kept in the
internal HashMap, which uses the sensor type as the key. |
android.hardware.Sensor |
lookupSensor(int sensorType) |
void |
registerSensor(android.hardware.Sensor sensor) |
void |
setSensorEvent(android.hardware.SensorEvent sensorEvent,
long unixTime)
Keep the given
SensorEvent object along with timestamp
in the internal HashMap. |
public void registerSensor(@NonNull android.hardware.Sensor sensor)
@Nullable public android.hardware.Sensor lookupSensor(int sensorType)
@NonNull public java.util.ArrayList<java.lang.Integer> getSensorTypes()
Sensor
objects on this device are kept in the
internal HashMap, which uses the sensor type as the key.
This method returns the sorted list of hash keys (= sensor types).@NonNull public java.lang.String getSensorTypeName(int sensorType)
Sensor
object has its own name such like
"Goldfish 3-axis Accelerometer", but it's arbitrarily named by
the device vendor and thus difficult to handle programmatically.
Instead, we use symbolic name derived from sensor type definitions.
For example, we take "accelerometer" from the constant value
"android.sensor.accelerometer", defined as
Sensor.STRING_TYPE_ACCELEROMETER
.sensorType
- Target sensor type, which is a hash key@NonNull public java.util.ArrayList<java.lang.String> getSensorTypeNames(@NonNull java.util.ArrayList<java.lang.Integer> sensorTypes)
sensorTypes
- ArrayList of target sensor typespublic void setSensorEvent(@NonNull android.hardware.SensorEvent sensorEvent, long unixTime)
SensorEvent
object along with timestamp
in the internal HashMap.sensorEvent
- the SensorEvent
object notified from systemunixTime
- timestamp of the notificationpublic java.util.ArrayList<SensorHolder> getSensorHolders()
SensorHolder
objects as the
latest collection of SensorEvent
object and timestamp.SensorHolder
objectspublic void clearSensorEvent()
SensorEvent
objects.