-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdonneesCapteur.java
27 lines (22 loc) · 918 Bytes
/
donneesCapteur.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private SensorManager mSensorManager;
private SensorEventListener mSensorListener;
////
mSensorManager = (SensorManager) this
.getSystemService(Context.SENSOR_SERVICE);
mSensorListener = new SensorEventListener() {
@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
}
@Override
public void onSensorChanged(SensorEvent event) {
Sensor sensor = event.sensor;
if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
//TODO: get values
}
else if (sensor.getType() == Sensor.TYPE_ORIENTATION) {
//TODO: get values
}
}
}
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME);