@Subscribe public synchronized void onEvent(SensorEvent event) { event = sensorEventTransformer.transform(event); double value = event.getValue(); String sensorName = event.getSensorName(); Sensor sensor = sensorManager.getSensorByName(sensorName); recentMeasurements.put(sensorName, value); Location location = getLocation(); if (location != null && sensor != null && sensor.isEnabled()) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); Measurement measurement = new Measurement(latitude, longitude, value, event.getMeasuredValue(), event.getDate()); if (state.recording().isRecording()) { MeasurementStream stream = prepareStream(event); tracker.addMeasurement(stream, measurement); } eventBus.post(new MeasurementEvent(measurement, sensor)); } }