/* * (non-Javadoc) * * @see de.unikassel.android.sdcframework.devices.AbstractAndroidSensorDevice# * doHandleSensorChanged(android.hardware.SensorEvent) */ @Override public final synchronized void doHandleSensorChanged(SensorEvent event) { if (event.values != null && event.values.length == 3) { currentSampleData.setAccelerationX(event.values[0]); currentSampleData.setAccelerationY(event.values[1]); currentSampleData.setAccelerationZ(event.values[2]); hasSample = true; } }
/** * Constructor * * @param context the application context */ public AccelerometerDevice(Context context) { super( SensorDeviceIdentifier.Accelerometer, Sensor.TYPE_ACCELEROMETER, context, SensorManager.SENSOR_DELAY_GAME); this.currentSampleData = new AccelerometerSampleData(); currentSampleData.setAccelerationX(Float.MIN_VALUE); currentSampleData.setAccelerationY(Float.MIN_VALUE); currentSampleData.setAccelerationZ(Float.MIN_VALUE); hasSample = false; }