Tag Archives: Xydroid

Writing Parcelable classes for Android

I’ve just released version 0.3 of Xydroid, my small Xymon monitoring app. It should now be a bit more suited to Android 2.0, and have just a couple fewer bugs in it.

As it turns out, the main problem with running under Android 2.0 for my app was de-parceling of a Parcelable representation of the XML files used by Xydroid. Up until now, I had just written out all the data in the tree when parceling, and read until no data was left when de-parceling. As it turns out, if this parcelable class is put into a bundle with other data, such as strings or integers, the de-parceling code will just continue reading along the bundle. The error I tended to encounter would be “Unmarshalling unknown type code 6946932” (or some other number), presumably as I tried to read a String from where an integer existed or similar.

The solution seems to be to write how much data you are planning to parcel as the first bit of information, and only read back this many chunks before passing control back. This works both in 2.0 and 1.5/1.6, whereas reading until there was no more data seemed to work in 1.5/1.6 but not 2.0 — though this might just have been pure luck.

Update: I thought I had better actually show how I ended up implementing my Parcelable classes, so here is a quick example of how to wrap a HashMap in something parcelable:
Continue reading

New SDK means strange new bugs

When I noticed the Android 2.0 software development kit had been launched, I hurried up and installed it. Okay, it did take the better part of 5 hours before it was properly installed, as Google’s servers were probably overloaded. None the less, I managed it at least, and fired up an Android 2.0 emulator, taking a moment to marvel at the fancy new settings that have been added for creating AVDs, before hurrying on to install my app, Xydroid.

As usual, it exhibited the crash right at first time start, probably as both the main thread and the update thread try to create the database, and they step on each others toes. I’ll be sure to get that fixed any day now. Somehow.

There’s also a new crash, though — this one is right after adding a new source, where the app tries to launch an activity that lets the user select the services to monitor. This gets a runtime error with a null pointer exception, whereas launching the activity separately, after the source has been added works fine. This could be a change in the way bundles between activities are handled in Android 2.0 versus 1.6.

I will probably have to get my act together and release a version 0.3 with these couple of bugs fixed, as well as plenty of testing done for differing screen sizes. One of the great advantages of Android can be said to be the number of different devices you can use it on — and it’s one of the major drawbacks as well, as there will always be a lot of different things to consider when designing the user interface. I do still prefer it over the iPhone, though 🙂

Xydroid – Xymon monitoring on Android phones

Finally, an update for the blog! Well, what has been going on with me? I’ve been busy at work, and perhaps even busier with my studies. I’m currently doing a course on Concurrency, which got me started on a bit of lovely threaded java programming again. It’s nice to be back to writing a bit of code, and boy have things gotten better over the few years since I last did anything major with it.

In other news, a couple of friends have bought themselves new Android phones, the HTC Hero. More and more of them are coming now, and it really looks like a wagon I’m liable to jump on any day now. They just need to release a new revision of the hardware, preferably something with one of the new Snapdragon CPUs in it …

So what could be more logical than to do a bit of programming for the Android platform? I struggled for a short while to figure out anything worthwhile to write, but then I came up with this: How nice would it be to get the status of your monitored systems direct on your phone? No more needing to browse to the hobbit Xymon system now, just a look at the phone to see how everything you care about is doing. Well, in theory. Except I don’t have the phone yet. Slight flaw in the plan.

None the less, I’ve made the software, in a sort of early beta version, and it’s available on a webpage of its own: Xydroid. Feel free to have a look .. if you want to actually use it, you should probably get in touch, and I’ll be sure to work on it enough that it will actually work properly as well.

After I’d started writing the software – actually, after I’d gotten quite far in the process – I found out that other’s have actually done the same as well, in the form of Xymon Monitor, for which they charge €2.99. Well, at least this might end up as the slightly cheaper alternative 🙂