Graph your battery usage [source code, for techies]

I came across something that belongs in the category “why didn’t I think of that” and wanted to share this with you.

One of the things I believe is very important to us all: How is the battery life on my phone. Mike Cardwell thought of the idea to gather the battery usage data from his phone and upload them to a server and graph them using the RRDTool.

Of course this is just one of the endless possibilities that this idea opens up… a few things that come to mind are: frequency of text messages sent/received and phone calls sent/received, duration of received/placed phonecalls, data usage, etc. Of course there are already applications out there that gather this kind of data and present this in a GUI on your phone but none (as far as I know) allow you to upload those data to a server.

In case you are interested, the source code is available here. If anything, it should be a good example for application developers of how to create persistent Android processes that don’t chew the battery, as it deals with alarms and cpu locking.