What's this?

WhereBlogger is a tool for Android phones, for keeping a location-based journal.

WhereBlogger can automatically collect GPS points for you, or you can add them manually. When an internet connection is available, maps will be downloaded for each logged point, and you can annotate each point with a title and a longer description. The program aims to be kind to your phone's battery and does not require a data connection or switch the GPS on at random times, as both electricity and data can be scarce while traveling.

Everything recorded by WhereBlogger can be published online (to a blog of your choice), or exported to the SD-card and copied to your PC to use as you see fit.

You can download WhereBlogger from the Android market (or just view the listing here).

Tuesday, October 27, 2009

Choosing an Android Maps API key at run-time

This is a little hint for any Android developers out there.

When using the Google MapView component in an Android app, you need a Maps API key which matches your app's signature. This is all fine and dandy, and pretty well explained on Google's web site.

However, a side-effect of how this is done means most developers are working with two different signatures on a daily basis: the signature of the debug key, which is autogenerated by the Android SDK, and their "production" signature which they use for publishing their apps to the market. Working with two signatures means you need two different Maps API keys as well, one for debugging and another for releases.

I didn't want to have to hand-edit constants in my code each time I built a release, and couldn't find any hints online on a more elegant solution, so I came up with the following snippet of code. This code will, at run-time, check which key was used to sign the app and then choose between two Maps API keys, based on whether it is a debug key or not.

static final String DEBUG_TAG = "YourApp";
static final String DEBUG_SIG = "...";
static final String DEBUG_KEY = "DEBUG KEY GOES HERE";
static final String RELEASE_KEY = "RELEASE KEY GOES HERE";
static String staticMapsApiKey = null;
public static String getMapsApiKey(Context context) {
if (staticMapsApiKey == null) {
try {
staticMapsApiKey = RELEASE_KEY;
Signature [] sigs = context.getPackageManager()
.getPackageInfo(context.getPackageName(),
PackageManager.GET_SIGNATURES)
.signatures;
for (int i = 0; i < sigs.length; i++) {
MessageDigest sha = MessageDigest.getInstance("SHA-1");
sha.update(sigs[i].toByteArray());
byte [] digest = sha.digest();
String str = "";
for (int di = 0; di < digest.length; di++) {
str += Byte.toString(digest[di])+":";
}
Log.d(DEBUG_TAG, "Got key sig: " + str);
if (str.equals(DEBUG_SIG)) {
Log.d(DEBUG_TAG, "Oh look, a debug signature!");
staticMapsApiKey = DEBUG_KEY;
break;
}
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
return staticMapsApiKey;
}

This code is admittedly rather ugly - a more experienced Java developer would probably write something a bit more elegant. But it gets the job done, once you have filled in all the constants at the top. The DEBUG_KEY and RELEASE_KEY strings should contain the keys you get from Google. The DEBUG_SIG constant can be filled in by running the code in debug mode, and searching the output of "adb logcat" for the "Got key sig: " message.

Hope this helps someone, and if anyone knows of a more elegant solution, please let me know!

Update: Sure enough, someone came up with a more elegant solution, based on this one. Cool! :-)

Monday, October 26, 2009

WhereBlogger 0.9.5

Major update this time:

  • The app now has a fancy map, both online and offline.
  • There is now a path recording mode, for actively keeping the GPS on and recording your movements as a path.
  • Points now have a toggle for 'Path ends here', telling the path drawing algorithms to not connect this point to the next one.
  • Minor bugfixes.

I had plenty of fun walking up and down the trails in the Los Cedros cloud forest reserve (awesome place, go there!) here in Ecuador, testing both the map and the path recorder.

The path recorder is pretty solid, and it's reasonably kind to the battery as well. By enabling flight-mode and keeping the screen off most of the time I was able to collect almost 7 hours worth of paths today, without emptying my droid's battery.

The map is also pretty well tested, points can be added, edited and deleted and the offline mode is usable. The latter still needs some work, primarily to do with how the map cache is populated, maintained and kept up to date. Also needed are better features for editing paths, and I want to add a visual map-based method for moving points around. Those features should all appear in future releases.

Wednesday, October 14, 2009

WhereBlogger 0.9.4

This will be the last release for a while, I am leaving Quito tomorrow to travel around Ecuador and make my way to Peru.

Updates:

  • Backup/restore now works and is documented.
  • Fixed most of the worst UI inconsistencies: trip list state is preserved while editing and the confusing double-tap/long-tap behavior is gone, instead there are nice buttons on the UI itself for the most common operations.
  • Minor bugfixes.


An example of the KML output generated by WhereBlogger may be seen here: these are my points and notes from our trip around the Galapagos Islands.

Tuesday, October 13, 2009

WhereBlogger 0.9.3

Changes since the last news post:

  • UI improvements (icons, whee!)
  • Added a 'Copy all' op to 'Trip ops'
  • Added a backup feature, to write dumps of the DB to the SD-card now and then.
  • Fixed the KML output to reproduce line-breaks, handle hidden points correctly and make the route-line less aggressively red.
  • Fixed minor bugs.

Sunday, October 11, 2009

WhereBlogger 0.9.1

Minor updates today:

  • Time zone handling is better now, the app will assume you keep the time-zone settings of your phone up-to-date and record those along with the GPS data for each point. Future versions should expose the time-zone offset for editing.
  • Points can now be marked as excursions ('Went right back'), which changes how the route is drawn in the KML file. Instead of the path continuing from an excursion point to the next, it returns to the last non-excursion point before continuing. For multi-point excursions, you are still going to need to re-add your 'base' when you return, if you want the route to be drawn correctly. The next feature makes that a bit less annoying...
  • Points can now be hidden. Hidden points won't show up in the trip view listing, and won't have (visible) placemarks in the generated KML files. There is a new Trip Op to hide all points with blank descriptions, so you don't have to edit each point by hand.
  • Cleaned up the JSON output a bit, the zoom field now has a sane name.
  • Added in-line help explaining excursion and hidden points to the point editor.


This is also the first on-the-fly database upgrade. Hopefully I got the code right and won't lose anyone's data. It worked fine on my phone anyway... :-)

Friday, October 9, 2009

WhereBlogger 0.9.0

Version 0.9.0 is the first public release of WhereBlogger. The app should be available for free on the Android Market.

Highlights of this release:

  • GPS points can be logged automatically or manually.
  • For each GPS point, you can write a title and a longer description.
  • GPS data can be edited after the fact (although the UI needs work).
  • You can have multiple trips recorded, and copy points between trips.
  • Trips can be exported to the SD card as KML, JSON and HTML.


Feel free to post any questions or opinions you may have about this release as comments to this post, but note that I am still traveling around South America (currently in Ecuador), so it may take me a little while to reply.