Posts Tagged ‘android’

Where did I meet you?

Tuesday, May 31st, 2011

a vcard importer for AndroidOverview

A bit of Android code to add comments to contacts imported from vCards to remind you how you know the person behind the vCard.


Remember poken? (Actually, “remember” isn’t fair, because they’re still around. I’ve just not seen them in an age.)

If you don’t, they were key-fob-sized gadgets. When you met someone, you tapped your poken against theirs, and it would handle exchanging contact details. They were a geeky way to exchange business cards.

They suffered from a bootstrap problem, in that, finding anyone else with a poken to tap against often proved a challenge. But I digress…

What I loved about them was that it didn’t only store the contact details, but details about when you met.


Using MQTT in Android mobile applications

Tuesday, February 1st, 2011


How to receive push notifications using MQTT in an Android mobile application


I’ve written before about MQTT as a technology for doing push notifications to mobile. When I wrote that, I gave an example Android project. However, it was the first time I’d ever done Android development, and while it was an okay Java MQTT sample, it was a poor Android sample – I didn’t know anything about how Android works as a platform.

I’ve since written other Android MQTT apps, such as a hackday app for pushing updates from websites to your phone and learnt a lot about how to do it properly. Well… if not properly, at least a little better.

But Google is still directing people to my old, and probably unhelpful, sample. So it’s about time that I share something more useful.

I’ve put the full source for a sample implementation below. (Note that I’m using the Java J2EE client library from Hopefully the comments in it are clear enough, but here are a few of the key points.


Programmatically identifying DVDs by their barcodes from Android

Thursday, December 30th, 2010


A few Android code snipperts for how to identify a DVD by it’s barcode


In November, I wrote a simple Android app that lets me add films to my LOVEFiLM list by taking a photo of a movie poster.

It also works by taking a photo of the front of a DVD case, as the DVD covers are essentially mini-posters. But a few people pointed out that using image recognition for the front of a DVD case is overkill, when DVD cases have a machine-readable barcode printed on them.

So I spent an evening adding the ability to scan barcodes to the app – and now you can add to your LOVEFiLM list either by photos of posters or barcodes.

I thought I’d quickly share how I did it, in case it’s useful to anyone else.


You need to ask if you want an Android to vibrate

Saturday, November 13th, 2010

I posted a few days ago about a new little app I stuck in the Android Market. An error report appeared from the app in the Market last night that I thought was interesting.

The app does some stuff in the background then when it’s finished, it sticks a notification in the top status bar. In my code, I just use the default notification settings – LED flash, vibrate, etc. And on every Android I’ve tested it on, it’s been fine.

But for one user, it caused the app to crash:

Exception class java.lang.SecurityException

Source method Parcel.readException()

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(
at java.util.concurrent.FutureTask$Sync.innerSetException(
at java.util.concurrent.FutureTask.setException(
at java.util.concurrent.FutureTask$Sync.innerRun(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.SecurityException: Requires VIBRATE permission
at android.os.Parcel.readException(
at android.os.Parcel.readException(
at android.os.AsyncTask$
at java.util.concurrent.FutureTask$Sync.innerRun(
... 4 more


A LOVEFiLM app for Android

Tuesday, November 9th, 2010

4 - LOVEFiLM - your finished photo
A simple Android utility app for a simple idea – adding DVDs to my LOVEFiLM queue while I’m out and about by taking photos of what I want to add.

(If you’ve not heard of LOVEFiLM before, they are an online DVD rental service: you use their website to set up a queue of DVDs you want to watch, they post you some, you watch them and post them back, and they send you some more.)

I love the service, but I never remember to add anything new to my queue. I’ve got a long queue of stuff to watch, but it’s all pretty old – months go by in between me remembering to visit the site.

And most of the time I think “oh, I’d love to watch that” I’m out and about. It could be walking past the Blockbuster Video store, or cinema in town and seeing a movie poster in the window. Or it could be seeing a DVD case in a shop or at a mates house. I think “I should add that to my LOVEFiLM queue when I get home”. And then promptly forget.

8 - LOVEFiLM - main screenSo last week, I started writing a quick Android app to help.

The idea is that whenever I see a movie poster or DVD cover now, I can snap a quick photo of it with my smartphone, then put the phone back in my pocket. Quick, one button press, no typing.

Then in the background, the app will try and work out what DVD I’ve taken a picture of, and then add it to my LOVEFiLM list.

It’s not always super-quick – it can take a minute or two – but, realistically that’s fine. It’s unlikely to make any difference to when LOVEFiLM will send me the DVD if it gets added to my queue now, in ten minutes, or even in a few hours time.

5 - LOVEFiLM - reviewing a problemWorst case scenario, if the app can’t figure out what the picture is, it can prompt me to let me know that it needs some help. The notification will sit in my phone’s status bar until I have some spare time to look at the photo, and manually type in the name of the DVD – which the app will then go and add to my queue.

This is still helpful though – I can trust that the app will somehow add the film to my queue, even if this means prompting me if it needs extra information.

It means I don’t forget to add it, because the app reminds me. And I don’t have to stand around typing in a name while I’m rushing around in town – if I need to do any typing at all, I can do it later when I have some spare time.

I’ve put a walkthrough of screenshots with an explanation of each stage on flickr.


UK Traffic Checker now in the Android Market

Monday, June 14th, 2010

Update: (April 2011) The app is no longer available

UK Traffic Checker for AndroidMy last post was a bit of a clue, but I still thought it was worth a mini-announcement that “UK Traffic Checker” is now available in the Android Market.

I wrote about the basic idea for the app when I first hacked it together, but to summarise it’s a mobile app that checks for roadworks or other traffic incidents on UK roads for a specific journey. Tell it two places, it will work out the route between them, and check that route for known problems.

And if you give it your schedule, it can automatically check traffic for you – with support for both one-off and repeating journeys. So if you have a regular commute, you can give it the details and it will check your route to work for you in the morning while you get ready, without you needing to remember to ask.

‘UK Traffic Checker’ in the Market


Releasing apps in the Android Market app store

Monday, June 14th, 2010

I’ve just added my first app to the Android Market app store, so I thought I’d write a quick post to share what is involved.

Note: This post isn’t aimed at mobile devs. The process is documented clearly enough that there really isn’t any need. Rather, this was more written at people who are probably never going to write and submit an app to a mobile app store, but who might have an idle curiosity about what is involved getting an app from a developer’s workstation to the app store.

Step 1 – Write the code

click to see full-size version - thanks to PhotobucketThis is really the fun bit 😉

The Android plugin for Eclipse gives you nice integration for publishing.

You can right-click on the project, choose “Export Signed Application Package” and the wizard spits out a signed file ready for publishing.

Step 2 – Register with Android

click to see full-size version - thanks to PhotobucketThis is the painful bit 🙁

You visit the Market site at and pay your $25 to register with Android as a developer. For me, it worked out to a bit over £17.


UK traffic news for Android

Thursday, May 6th, 2010

Update: (April 2011) The app is no longer available

I’ve been travelling a lot for work recently. Most of it has been by car, and on a few occasions, I’ve run into traffic problems that have made me late.

This got me thinking about what I could do to make things easier.

There are websites with traffic info – such as the Highways Agency or motoring organisations like the AA and RAC. They show travel information for a particular region, or the UK as a whole.

But that’s not really enough.

For one thing, I have to remember to check. I’m not a morning person – particularly when I need to get up at 5am so I can drive for hours. Any approach that relies on me remembering to do something isn’t off to a great start.

And it’s too manual. They show me all of the traffic problems, and it’s up to me to manually work out which of them might affect my route. There is too much noise, with too many traffic reports for places that are nowhere near me, or where I want to go. It’s up to me to filter that out.

At any rate, I don’t want to boot up a computer at 5am, so an AJAX-heavy website that doesn’t work on mobiles isn’t an ideal fit anyway.

My ideal approach would be:

My mobile phone is already my alarm clock. It’s the only screen I look at when I get up in the morning, so this is the ideal place to get traffic info.

My mobile knows when I’m going to go somewhere, and where I’m planning to go. It shouldn’t need me to manually check every day – it should check for me automatically, and alert me if it finds any problems.

Showing me every traffic problem is too much. My mobile knows where I am, and where I’m going. I only want to see problems that are on (or perhaps very near) my route. Anything else should be filtered out, leaving me with just the updates relevant to me.

I went looking for a mobile app that does this, but didn’t have any luck. There are a couple of Android apps with UK traffic information (one from the RAC, the other by the brilliant Simon Judge).

They at least get the traffic info into a mobile-friendly format. But they still show you every traffic problem, and only when you remember to check. I couldn’t find anything that meets all three of my needs.

So I’ve written one.

It’s basic looking… and perhaps a little rough around the edges. But it’s a start.

You enter in routes – which is a start and an end location. This can be a town or city name, a full address, or a postcode.

From there, you can either check the traffic now, or schedule the app to check at a later date and time. For regular journeys, you can describe a repeating pattern – so for example, I can tell it to check my route to work every weekday morning at 7am, and my route home every weekday evening at 4.45pm.

The app works out the route, and compares it with known traffic problems.

This can be done in the background, so it doesn’t matter if your phone is switched off when it’s time to check, or if you’re using another app.

If it finds any matches, it puts a warning in the notifications bar. Tapping on this can take you to a list of the problem descriptions, or an interactive map with both the route and the traffic problems marked on it.

It’s pretty neat, even if I say so myself. 🙂

And it’s something that I can see myself using.

So why am I not making it available for others now? I’ll leave that for another post…