Showing
1 changed file
with
10 additions
and
1 deletions
| ... | @@ -85,6 +85,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -85,6 +85,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
| 85 | private double mSpeed = 0; | 85 | private double mSpeed = 0; |
| 86 | private int orientationCount = 0, touchCount = 0; | 86 | private int orientationCount = 0, touchCount = 0; |
| 87 | final long REFRESH_TIME = 100; // miliseconds | 87 | final long REFRESH_TIME = 100; // miliseconds |
| 88 | + private String mStartTimestamp = "", mStopTimestamp = ""; | ||
| 88 | 89 | ||
| 89 | 90 | ||
| 90 | // =========================================================== | 91 | // =========================================================== |
| ... | @@ -375,6 +376,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -375,6 +376,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
| 375 | } | 376 | } |
| 376 | 377 | ||
| 377 | private void registerSensor() { | 378 | private void registerSensor() { |
| 379 | + mStartTimestamp = String.valueOf(System.currentTimeMillis()); | ||
| 378 | mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); | 380 | mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); |
| 379 | mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | 381 | mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); |
| 380 | mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); | 382 | mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); |
| ... | @@ -390,11 +392,17 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -390,11 +392,17 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
| 390 | try { | 392 | try { |
| 391 | JSONObject jobj = new JSONObject(); | 393 | JSONObject jobj = new JSONObject(); |
| 392 | JSONObject jobjData = new JSONObject(); | 394 | JSONObject jobjData = new JSONObject(); |
| 395 | + String timestamp = String.valueOf(System.currentTimeMillis()); | ||
| 393 | jobjData.putOpt("acceleration", mAcceleration); | 396 | jobjData.putOpt("acceleration", mAcceleration); |
| 394 | jobjData.putOpt("speed", mSpeed); | 397 | jobjData.putOpt("speed", mSpeed); |
| 395 | jobjData.putOpt("orientation_count", orientationCount); | 398 | jobjData.putOpt("orientation_count", orientationCount); |
| 396 | jobjData.putOpt("touch_count", touchCount); | 399 | jobjData.putOpt("touch_count", touchCount); |
| 397 | - jobj.putOpt(String.valueOf(System.currentTimeMillis()), jobjData); | 400 | + jobjData.putOpt("timestamp", timestamp); |
| 401 | + jobjData.putOpt("start_time", mStartTimestamp); | ||
| 402 | + jobjData.putOpt("stop_time", mStopTimestamp); | ||
| 403 | + jobjData.putOpt("latitude",mLatitude); | ||
| 404 | + jobjData.putOpt("longitude", mLongitude); | ||
| 405 | + jobj.putOpt(timestamp, jobjData); | ||
| 398 | mAccelerationTimestamps.add(jobj); | 406 | mAccelerationTimestamps.add(jobj); |
| 399 | recordsCount[0]++; | 407 | recordsCount[0]++; |
| 400 | mTvRecordsSaved.setText(String.valueOf(recordsCount[0])); | 408 | mTvRecordsSaved.setText(String.valueOf(recordsCount[0])); |
| ... | @@ -409,6 +417,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener | ... | @@ -409,6 +417,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener |
| 409 | } | 417 | } |
| 410 | 418 | ||
| 411 | private void unregisterSensor() { | 419 | private void unregisterSensor() { |
| 420 | + mStopTimestamp = String.valueOf(System.currentTimeMillis()); | ||
| 412 | orientationCount = 0; | 421 | orientationCount = 0; |
| 413 | touchCount = 0; | 422 | touchCount = 0; |
| 414 | mSensorManager.unregisterListener(this); | 423 | mSensorManager.unregisterListener(this); | ... | ... |
-
Please register or login to post a comment