Tag Archives: my tracks

My Tracks v2.0

This is a real quick post as a heads up. The My Tracks guys have just shipped a pretty major update to My Tracks. This update has changed a load of things including how you export tracks for Tracks2Miles to upload them to Dailymile.

I’ve just pushed a real quick update (I hope I’ve not broken anything) with a fix for an interface that changed, without the fix Tracks2Miles will crash when you try to export a workout with the new My Tracks.

I was hoping to ship Tracks2Miles v2.0 at the same time My Tracks v2.0 shipped but I’ve been really busy with work so not been able to get it finished in time. I hope to get it all done over the next few weekends so I can get it out soon.

Exporting workouts has got a little bit more convoluted with the new My Tracks so I’ll try and do a new walk through video as well.

Tracks2Miles 1.1.10

Just a quick update while I’m still working on a 2.x release*.

This release has 2 updates:

  1. A small update to the import code to make use of the patch I managed to get included in the latest (1.1.11) release of My Tracks
  2. A new setting in the preferences to block uploading GPX data with a workout imported from My Tracks. This was a feature requested to help people with privacy concerns

You can download Tracks2Miles here: https://market.android.com/details?id=uk.me.hardill.dailymile

* The plan is for 2.x to have a updated UI making use of fragments for tablet and ICS devices.

New My Tracks Patch

After my last My Tracks patch had to be pulled (to be honest it did break sharing routes by anything other than Tracks2Miles) a new (safe) patch was accepted a few days ago.

This patch passes just the My Tracks track id along with the URL for the exported file in the SHARE intent. The key for the extra reuses the same key that is used by the My Tracks library when sending Broadcasts on starting and stopping recording a new track. The track id can be recovered from the intent with the following code:

long track_id = 
    intent.getLongExtra(getString(R.string.track_id_broadcast_extra), -1);

Once you have the track id then looking up all the details of that track using the My Tracks Library project is trivial (Once you got the user to allow 3rd party apps access).

MyTracksProviderUtils utils = 
    new MyTracksProviderUtilsImpl(this.getContentResolver());
Track track = utils.getTrack(track_id);
TripStatistics stats = track.getStatistics();
double totalDistance = stats.getTotalDistance();
long movingTime = stats.getMovingTime();
String cat = track.getCategory();
String desc = track.getDescription();
long lastLocId = utils.getLastLocationId(track_id);
Location loc = utils.getLocation(lastLocId);

The latest version of Tracks2TitanXT has already been updated to use this method and Tracks2Miles will get an update for this as well as some better tablet support before the next version of My Tracks ships.

Tracks2TitanXT

About a month ago I was approached by Erik Morse from TitanXT to ask if I would be prepared to do something similar to Tracks2Miles for his site. At the time he did not have an API available, I said if he could run some thing up I would be prepared to have a look. Last week he sent me the details so I spent some of the long weekend running up a first pass of an app.

So Tracks2Miles now has a sister app supporting the TitanXT site called Tracks2TitanXT.

It works in much the same way as Tracks2Miles in that it hooks into My Tracks through the “Share with Friends…” option, except as well as supporting GPX files TitanXT supports the uploading of TCX files which also contain heart rate information if you are using one of the Bluetooth heart rate monitors that My Tracks supports.

The first pass is in the Android Market, it needs a few more bits of error handling and some cosmetic changes but I thought I’d let those that want to have play.

YouTube Preview Image

https://market.android.com/details?id=uk.me.hardill.titanxt

Tracks2Mile 1.1.4 – With automatic details import

After discovering that my patch for My Tracks had been pulled just before their last release (1.1.5) I’ve been looking for another way to get the information about time and distance.

After another closer look at the instructions 3rd party use instruction on the wiki and it’s possible to access the My Tracks database directly. Running a query that filters on the workout title, which I can get from the GPX files name, I can get hold of all the information. It is possible to have multiple workouts with the same name so I’m picking the last one added to the db since this has to be the most likely one you’ll be wanting to upload.

Since I’m reading direct from the database there is also the problem that if the My Tracks guys change the table layout then I could have a problem. The API provides a method that returns a Track object which holds the data but you can only use this if you know workout id, but this available at the moment.

I’ll probably stick a new patch in for My Tracks to pass the workout id so I don’t have to make this assumption, but it should be good enough for now.

Other fixes include:

  • One to stop caching photos in memory before writing them to the sd card to prevent OutOfMemoryErrors
  • Closed a couple of windows where the database was accessed after it’s been closed.

Grab it from the Android Market here

My Tracks patch pulled

So it looks like my patch to My Tracks to get it to expose the extra information needed for Tracks2Miles got pulled just before the last release because it broke the export to GMail (and dropbox).

It’s a shame it got spotted so close to the release of My Tracks 1.1.5 I didn’t get chance to look at before it went out.

It looks like Android resolves and unpacks all the Parcellable extras upfront even if they are not used by the receiving Activity or Service. So apps not expecting the Track object I was using fail with ClassNotFoundException because it’s not available.

I’ll try and find some time to come up with a new solution as soon as I get some time to think about it properly.

Tracks2Miles 1.1.0

The latest Tracks2Miles update

Added a timeline view to see what you friends have been up to.

*** Edit ***

I’ve just noticed that on some phones that after the update the launch icon will still open the Activity for publishing a new workout rather than the Timeline Activity. This is a “feature” of some of the launchers, you may need to restart your phone to get it to see the update.

*** Edit ***

Fixed up a couple of race condition type problems.

Updated the code to import from My Tracks to use the patch that has been accepted for the next release.

My Tracks Patched

The guys at My Tracks have integrated the changes I sent to enable more data to be passed with the GPX file. There are some slight changes needed to the currently released version of Tracks2Miles but I will push a new version in the next couple of days to be ready for the next My Tracks drop.

I don’t know when the next version of My Tracks will ship yet, but we will be ready,

In the meantime here are the details of the change so others can use it to build similar add-ons for any other site (why they would want to use anything but dailymile?).

As mentioned back in the first post on this subject your going to need an Intent filter that will trap when My Tracks is looking to export a GPX file (the changes to My Tracks apply to all file types, but I’m only going to talk about GPX here). The following is what I’ve been using for Tracks2Miles:

 <activity android:name=".Export"
      android:label="@string/app_name" android:exported="true">
   <intent-filter>
     <action android:name="android.intent.action.SEND" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:mimeType="application/gpx+xml" />
   </intent-filter>
 </activity>

This hooks the “android.intent.action.SEND” action and filters it for the mimeType “application/gpx+xml”. So in the Activity that gets called when an intent matching this is broadcast you will need a onCreate method that looks something like this.

public void onCreate(Bundle savedInstanceState) {
  Intent intent = getIntent();

  if (intent.getAction().equals(Intent.ACTION_SEND)) {
    if (intent.hasExtra("com.google.android.apps.mytracks.TRACK")) {
      Track track = (Track) intent.getParcelableExtra("com.google.android.apps.mytracks.TRACK");
      ...
    }

    Uri gpxURI = (Uri)intent.getExtras().get(Intent.EXTRA_STREAM);
    ...
  }
}

Where Track is an instance of com.google.android.apps.mytracks.content.Track. You will need to grab this and the 2 classes in the package com.google.android.apps.mytracks.stats so they can be on the classpath for getParcelableExtra to find them. From the Track object you can get hold of name, time and distance of the workout and also there is a Statistics field that has info on average/max speed, elevation information.

I’m planning on writing a My Tracks wiki page about this some time soon where I’ll go in to a little bit more detail but this should get most people started.