private void startLiveData() {
    Log.d(TAG, "Starting live data..");

    tl.removeAllViews(); // start fresh
    doBindService();

    currentTrip = triplog.startTrip();
    if (currentTrip == null) showDialog(SAVE_TRIP_NOT_AVAILABLE);

    // start command execution
    new Handler().post(mQueueCommands);

    if (prefs.getBoolean(ConfigActivity.ENABLE_GPS_KEY, false)) gpsStart();
    else gpsStatusTextView.setText(getString(R.string.status_gps_not_used));

    // screen won't turn off until wakeLock.release()
    wakeLock.acquire();

    if (prefs.getBoolean(ConfigActivity.ENABLE_FULL_LOGGING_KEY, false)) {

      // Create the CSV Logger
      long mils = System.currentTimeMillis();
      SimpleDateFormat sdf = new SimpleDateFormat("_dd_MM_yyyy_HH_mm_ss");

      myCSVWriter =
          new LogCSVWriter(
              "Log" + sdf.format(new Date(mils)).toString() + ".csv",
              prefs.getString(
                  ConfigActivity.DIRECTORY_FULL_LOGGING_KEY,
                  getString(R.string.default_dirname_full_logging)));
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
    if (btAdapter != null) bluetoothDefaultIsEnable = btAdapter.isEnabled();

    // get Orientation sensor
    List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
    if (sensors.size() > 0) orientSensor = sensors.get(0);
    else showDialog(NO_ORIENTATION_SENSOR);

    context = this.getApplicationContext();
    // create a log instance for use by this application
    triplog = TripLog.getInstance(context);
  }
 protected void endTrip() {
   if (currentTrip != null) {
     currentTrip.setEndDate(new Date());
     triplog.updateRecord(currentTrip);
   }
 }