private long startNewTrack(){
  if (isRecording()) {
    Log.d(TAG,"Ignore startNewTrack. Already recording.");
    return -1L;
  }
  long now=System.currentTimeMillis();
  trackTripStatisticsUpdater=new TripStatisticsUpdater(now);
  markerTripStatisticsUpdater=new TripStatisticsUpdater(now);
  Track track=new Track();
  Uri uri=myTracksProviderUtils.insertTrack(track);
  long trackId=Long.parseLong(uri.getLastPathSegment());
  updateRecordingState(trackId,false);
  PreferencesUtils.setInt(this,R.string.auto_resume_track_current_retry_key,0);
  PreferencesUtils.setInt(this,R.string.activity_recognition_type_key,PreferencesUtils.ACTIVITY_RECOGNITION_TYPE_DEFAULT);
  track.setId(trackId);
  track.setName(TrackNameUtils.getTrackName(this,trackId,now,null));
  String category=PreferencesUtils.getString(this,R.string.default_activity_key,PreferencesUtils.DEFAULT_ACTIVITY_DEFAULT);
  track.setCategory(category);
  track.setIcon(TrackIconUtils.getIconValue(this,category));
  track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
  myTracksProviderUtils.updateTrack(track);
  insertWaypoint(WaypointCreationRequest.DEFAULT_START_TRACK);
  startRecording(true);
  return trackId;
}

private long startNewTrack ( ) { if ( isRecording ( ) ) { Log . d ( TAG , "Ignore startNewTrack. Already recording." ) ; return - 1L ; } long now = System . currentTimeMillis ( ) ; trackTripStatisticsUpdater = new TripStatisticsUpdater ( now ) ; markerTripStatisticsUpdater = new TripStatisticsUpdater ( now ) ; Track track = new Track ( ) ; Uri uri = myTracksProviderUtils . insertTrack ( track ) ; long trackId = Long . parseLong ( uri . getLastPathSegment ( ) ) ; updateRecordingState ( trackId , false ) ; PreferencesUtils . setInt ( this , R . string . auto_resume_track_current_retry_key , 0 ) ; PreferencesUtils . setInt ( this , R . string . activity_recognition_type_key , PreferencesUtils . ACTIVITY_RECOGNITION_TYPE_DEFAULT ) ; track . setId ( trackId ) ; track . setName ( TrackNameUtils . getTrackName ( this , trackId , now , null ) ) ; String category = PreferencesUtils . getString ( this , R . string . default_activity_key , PreferencesUtils . DEFAULT_ACTIVITY_DEFAULT ) ; track . setCategory ( category ) ; track . setIcon ( TrackIconUtils . getIconValue ( this , category ) ) ; track . setTripStatistics ( trackTripStatisticsUpdater . getTripStatistics ( ) ) ; myTracksProviderUtils . updateTrack ( track ) ; insertWaypoint ( WaypointCreationRequest . DEFAULT_START_TRACK ) ; startRecording ( true ) ; return trackId ; }
starts a new track .
