Monthly Archives: October 2009

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 🙂

What are Google going to do about PIM? Well, more…

A short while ago, I asked what Google were going to do with PIM in Android. Now it seems there’s an answer, or at least part of it, in the release of the Android 2.0 SDK: They’re going to support third party adapters.

The nice people at Engadget have a summary of some of the changes, and among them one can find:

  • Third-party “sync adapters” allow apps to tie in to the phone’s sync services

Hopefully, this means they’re actually going to start working on some nice built-in adapters as well, but at least it seems they’re opening up the sync parts of the platform from 2.0, contrary to what had earlier been reported. Yay.

Android: What are Google going to do with PIM?

From the early days of palm-top devices, through early smartphones like the Nokia Communicator, and up to all the iPhones, Androids and BlackBerrys of today, what the serious users have been looking for has always been PIM: Personal Information Management. They are looking to have their email, calendar, contacts and notes available at all times, on a small portable device. Indeed, as am I. I have been using my Nokia N95 for a couple of years now, and there really is something to be said for having my calendar with me at all times, just by the virtue of carrying my phone.

So what have Google done with Android? They’ve put Google Mail, Google Calendar and a Contacts synchronization to Google Mail in their fine mobile operating system, which goes some of the way. They have also, I am told, put in a regular IMAP client, for those people who don’t use Google Mail, for instance for corporate email. But, it seems, the fun ends there.

There’s no direct support for SyncML, and nothing, it seems, for Exchange. Sure, you can go through Google Calendar for your calendar syncs, and I presume you can forward your mail to Gmail – if your corporate policy permits that. But when it comes to direct sync for third party providers, no luck.

It’s starting to look a bit like what some of us have criticized Apple’s software for doing: If you don’t use it like Steve Jobs does, you’re out of luck. In this case though, even more so: If you don’t buy into Google’s services, no luck with Android’s default apps.

So someone could just develop a sync adapter for the built-in calendar. The source is available under the Apache license, so why not? Here’s why: Google have stated that the API for the built-in Calendar is not public and not going to be for 1.6 or 2.0, which leaves a worrying question: Are Google only going support their own services from the base OS?

It’s certainly not completely unthinkable, as Android has been hailed as an open platform, so anyone can just code a Calendar app, right. Right? Well, maybe. But selling smartphones with no proper PIM solution for anything else than a single provider doesn’t seem like a viable business to me, and I really do hope Google make up their mind to do things differently, and support direct over-the-air synchronization with SyncML, CalDav or even Exchange systems.

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 🙂