DeadReckoning implements SensorEventListener, SensorCollector, DownloadListener<Map<String, Collection>> { boolean detectMovement() { final float x = valuesLinearAcceleration[0]; final float y = valuesLinearAcceleration[1]; final float z = valuesLinearAcceleration[2]; final float vectorLength = x*x + y*y + z*z; final boolean isMoving = (vectorLength >= movementDetectionSensitivity); return isMoving; } DeadReckoning(final Activity activity); void startSensors(); void stopSensors(); @Override void onDownloadFinished(DownloadTask task, boolean success, Map<String, Collection> data); @Override void onSensorChanged(final SensorEvent event); @Override void onAccuracyChanged(final Sensor sensor, final int accuracy); NicGeoPoint getDelta(); void setCompassFilterEnabled(boolean useLowPassFilter); void setBaseAngle(final double baseAngle);  }
@Test public void testDetectMovement() { deadReckoning.valuesLinearAcceleration[0] = 1.7f; deadReckoning.valuesLinearAcceleration[1] = 0.f; deadReckoning.valuesLinearAcceleration[2] = 0.f; deadReckoning.movementDetectionSensitivity = 2.25f; assertTrue(deadReckoning.detectMovement()); }
@Test public void testNoDetectMovement() { deadReckoning.valuesLinearAcceleration[0] = 0.3f; deadReckoning.valuesLinearAcceleration[1] = 1.2f; deadReckoning.valuesLinearAcceleration[2] = 0.8f; deadReckoning.movementDetectionSensitivity = 2.25f; assertFalse(deadReckoning.detectMovement()); }