Panagiotis Triantafyllou

telematics addition

......@@ -85,6 +85,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private double mSpeed = 0;
private int orientationCount = 0, touchCount = 0;
final long REFRESH_TIME = 100; // miliseconds
private String mStartTimestamp = "", mStopTimestamp = "";
// ===========================================================
......@@ -375,6 +376,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
private void registerSensor() {
mStartTimestamp = String.valueOf(System.currentTimeMillis());
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
......@@ -390,11 +392,17 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
try {
JSONObject jobj = new JSONObject();
JSONObject jobjData = new JSONObject();
String timestamp = String.valueOf(System.currentTimeMillis());
jobjData.putOpt("acceleration", mAcceleration);
jobjData.putOpt("speed", mSpeed);
jobjData.putOpt("orientation_count", orientationCount);
jobjData.putOpt("touch_count", touchCount);
jobj.putOpt(String.valueOf(System.currentTimeMillis()), jobjData);
jobjData.putOpt("timestamp", timestamp);
jobjData.putOpt("start_time", mStartTimestamp);
jobjData.putOpt("stop_time", mStopTimestamp);
jobjData.putOpt("latitude",mLatitude);
jobjData.putOpt("longitude", mLongitude);
jobj.putOpt(timestamp, jobjData);
mAccelerationTimestamps.add(jobj);
recordsCount[0]++;
mTvRecordsSaved.setText(String.valueOf(recordsCount[0]));
......@@ -409,6 +417,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
}
private void unregisterSensor() {
mStopTimestamp = String.valueOf(System.currentTimeMillis());
orientationCount = 0;
touchCount = 0;
mSensorManager.unregisterListener(this);
......