MOVERIO Pro Developer's Guide (Rev.1.4)
118
7.3.
Using SensorEventListener
It is necessary to implement SensorEventListener for sensors using Activity or Service.
Example: Implementing SensorEventListener in Activity
public
class
SampleActivity
extends
Activity
implements
SensorEventListener
7.3.1.
Registering sensors being used
When using a sensor, you need to register a sensor listener.
Example) Registering an accelerometer
//System sensor service acquisition
SensorManager sm = (SensorManager)getSystemService(
SENSOR_SERVICE
);
//Registering an accelerometer (
TYPE_ACCELEROMETER
)
Sensor s = sm.getDefaultSensor(Sensor.
TYPE_ACCELEROMETER
);
sm.registerListener(
this
, s, SensorManager.
SENSOR_DELAY_NORMAL
);
7.3.2.
Acquiring a sensor value
You can use the sensor value by acquiring a sensor event in onSensorChanged for SensorEventListener.
Example) Acquiring a sensor value for the accelerometer
@Override
public
void
onSensorChanged(SensorEvent event) {
//Acquiring the accelerometer value (display log)
if
(event.
sensor
.getType() == Sensor.
TYPE_ACCELEROMETER
){
Log.
d
(
"Sample"
,
"ax="
+event.
values
[0]+
",ay="
+event.
values
[1]+
",az="
+event.
values
[2]);
}
}
Summary of Contents for Moverio Pro BT-2000
Page 7: ...MOVERIO Pro Developer s Guide Rev 1 4 1 1 Introduction ...
Page 12: ...MOVERIO Pro Developer s Guide Rev 1 4 6 2 Developing Apps ...
Page 30: ...MOVERIO Pro Developer s Guide Rev 1 4 24 3 Display control ...
Page 39: ...MOVERIO Pro Developer s Guide Rev 1 4 33 4 UI control ...
Page 47: ...MOVERIO Pro Developer s Guide Rev 1 4 41 5 Voice commands ...
Page 70: ...MOVERIO Pro Developer s Guide Rev 1 4 64 6 Camera control ...
Page 119: ...MOVERIO Pro Developer s Guide Rev 1 4 113 7 Sensor control ...
Page 127: ...MOVERIO Pro Developer s Guide Rev 1 4 121 8 Bluetooth BLE ...
Page 184: ...MOVERIO Pro Developer s Guide Rev 1 4 178 9 Power control ...
Page 187: ...MOVERIO Pro Developer s Guide Rev 1 4 181 10 Self diagnostic function ...
Page 191: ...MOVERIO Pro Developer s Guide Rev 1 4 185 11 GPS Assist ...
Page 202: ...MOVERIO Pro Developer s Guide Rev 1 4 196 Memo ...