Archive for the ‘code’ Category

Why I haven’t written TwitToday for Android

Thursday, February 25th, 2010

(or “looking at the limitations of the Android home screen widgets framework”)

Twitter client for Windows MobileA couple of years ago, I wrote a Windows Mobile app called TwitToday : a Twitter widget for the “Today screen” (the default screen when the phone is on, with all apps closed or minimised).

The rationale was that it was useful to have a way to post a tweet quickly when you don’t want to have to wait for a full-blown client to start.

Or if you don’t want to incur the battery or memory cost of leaving a client running all the time.


A widget that doesn't work on AndroidAndroid has a “Home screen”, which is similar to the Today screen on Windows Mobile. And it has support for widgets. This led several people to ask me why I never ported TwitToday to Android.

The short answer is that I did try, but the current state of the widgets framework made it impossible.

I tried to write a TwitToday widget back when the Android widgets framework was first introduced in Android 1.5.

It all started quite well:

  1. I wrote the Android Service that would carry out the background task of posting a tweet. No problems there – it worked fine.
  2. I wrote the widget XML to define the GUI. This is what you can see running in the screenshot. And it works… sort of. It has a text box that you can type up to 140 characters into. And if you press the button, it causes a chunk of code to get invoked.

The problem came when I tried to link the two together: to get the Service that posts tweets to obtain the String from the text box in my widget.

This isn’t possible. Android’s widget framework as it currently stands is geared around displaying information to the user, not collecting user input.

(more…)

Using my mobile as a TV remote control for vdr

Monday, February 22nd, 2010

remote controlsI can never find the TV remote.

Whether it’s slipped somewhere in or under the sofa, or been hidden by the kids, I’m often at a loss to find it.

A mobile phone, on the other hand, is rarely too far from my hand 🙂

So I’ve hacked together a quick app to put a TV remote control interface on my phone. It’s definitely a quick-and-dirty chunk of code, but it does now mean that I can work my TV from my mobile if I can’t find the real remote.

On the off-chance that this is useful to other vdr users, I wanted to share how I did it.

(more…)

last.fm for television

Wednesday, January 6th, 2010

One of the social network sites I’ve been using the longest is last.fm.

(If you know what last.fm is, bear with me teaching you to suck eggs for a few paragraphs… it gets more interesting – honest!)

The idea of last.fm is that a background service captures (or “scrobbles“) the music that I listen to on my computer at home, on the mp3 player that I use in the car, and on my laptop in the office.

This means that I now have a large record detailing the music I’ve listened to over the last three years.

I do this for a few reasons, including:

  • The data is made available to me through a rich API, which means I’m free to play with it, as well as take advantage of the creations of others, such as the wonderful visualisations generated by lastgraph
  • I can see what my friends listen to, which is interesting, as well as being a good way to come across new music
  • last.fm use this detailed history of my music-listening tastes to make automated recommendations of other music that I might like

This is all a long-winded way of saying that I like last.fm. I find it useful and interesting, and want the same for all the media that I consume – not just music.

I went looking for an equivalent for the books that I read in August 2008, and started using goodreads.

But what about the television that I watch? Could I create a last.fm-style scrobbler to capture what I watch on television? And then try and come up with a few examples of how I could share and visualise the data?

This question is where I started at Christmas… and after a few evenings of hacking some Python together, I’ve come up with:

last.fm for television

Please go take a look. (needs Flash – sorry)

(more…)

How much did I spend on electricity to do that?

Friday, November 27th, 2009

Selecting a chunk of a graphTime for number 73 in my never-ending list of ever-so-slightly-different things to try with a graph of home energy usage data

🙂

This time… working out the electricity used (and the cost) of doing… well, something in particular.

We already have live graphs (Switch something on and watch the graph shoot up. Switch it off and watch the line drop.)

And we’ve already got graphs with hourly, daily, or monthly totals.

But if I boil a kettle, how do I know how much that cost?

The live graph shows you the shape of the usage curve for a particular appliance.

What I wanted was to be able to start the live graph running, switch something on, then after it’s finished, go back to the live graph, see the bump in the graph for when I did that, and measure the area under it – giving me my total energy usage for that time.

A quick bit of Python-tinkering later, and here we go

Click-and-drag to highlight a span of the graph, and the Python script calculates the area (more-or-less) under that part of the curve, using this to calculate how much energy I used during this time.

(more…)

Augmented reality for Hursley

Friday, November 6th, 2009

screenshot : click for better resolution imageOne of the themes at openMIC this week was augmented reality, and a topic that came up a couple of times was Layar.

Layar is a mobile app for Android and iPhone that lets you display location-based information overlaid on a real-time camera view.

For example, the screen normally shows a viewfinder-like view from your mobile’s camera.

Search for “coffee” and a bunch of markers appear on the view, showing you where the nearest coffee shops are.

As you move the phone around, the markers follow the approximate location of the places they are showing you.

That’s assuming you want to search ‘Google Local’, but that’s not the only option. Location data is provided through “layars”, and there are layars available for location-tagged Wikipedia articles, Flickr photos, brightkite users, and more.

The interesting thing talked about at openMIC was the Layar API which lets anyone create a new Layar with their own information.

So I decided to spend a quiet Friday afternoon in the office creating a Layar for around Hursley. 🙂

This means a phone with the Layar browser installed can browse and search for points of interest around the site.

It was really very easy, so I’ll quickly outline the steps involved.

(more…)

Tracking my location on TV

Wednesday, October 21st, 2009

Location tracking on TV

This is what you see if you press the “Find Dale” button on my TV remote control.

(Well, actually the “Teletext” button… cos I wasn’t using it, and there isn’t another button that makes any more sense!)

The on-screen-display adds a message at the bottom of the screen for a few seconds, saying my last recorded location and when I was there.

People following me on twitter may have noticed me talking about setting up a new home media server: a small Linux server that has become our Freeview box, PVR, home photo album, and music server.

And now it’s set up, it is surprisingly easy to do amazingly useful, and not-at-all annoying things like this! 😉

In my defence, I stopped just short of making the script poll for my location and display an on-screen message whenever my location changes. Which would’ve been very cool, but probably drive my family nuts. So I compromised with a script that runs when you press a button on the remote.

(more…)

OAuth authentication from a mobile device

Monday, August 31st, 2009

I wrote a post a couple of weeks ago in which I whined about the difficulties in creating a good user experience for a mobile client that authenticates with an OAuth provider.

I was pleasantly surprised (and a little honoured!) to get a comment on the post from Chris Messina reminding me that the way to address the usability issue isn’t to revert back to using usernames and passwords, but for us to all work to improve the usability of OAuth.

Sufficiently inspired, I went back and had another go.

It’s still not quite there, but I think it’s better.

As Andy pointed out last time, not everyone has a Windows Mobile device to try my code on, so this time I tried recording a screen capture of it.

(more…)

(Another!) Mobile app to share where you are

Saturday, August 29th, 2009

Mobile location sharing is something that I keep coming back to: from finding where my phone is using GPS, Bluetooth, WiFi Access Points, GSM Cell Ids, using my own hand-rolled systems or newer services like Google Latitude, dopplr, OpenCellID and Brightkite.

There is something about the promise of location-based apps which I find very exciting.

This is my excuse, at any rate, for sharing my latest bit of tinkering. 🙂

The stuff that I’ve tried so far has been focused on long-term sharing – apps intended to run in the background on your phone all the time, sharing your location with a pre-arranged list of friends and family who have signed up to the same service.

I’m playing with an app which comes at this from the other angle: an app for specific occasions to share your location. Not something to run in the background all the time, but an app to use when you want to let someone know where you are – a specific person. This could be a friend or family member, or a colleague or client (perhaps someone who hasn’t signed up to any service that you have).

(more…)