HTC Magic, Month 1: Back to geek world

After a few days of enthusiasm, I stopped sharing my thoughts about the HTC Magic. What happened? Two things. First, there was work, eating my time. And then, there was something else, that seems to happen to all the Android phone owners I know: I downloaded the SDK.

So what? Well, I started programming something, which happens to be a game for my 3-year old son, currently passionate about spelling and recognizing words. And that brought me back to my natural, geeky state, busy in front of my keyboard on evenings. So now, I can tell you about my first experience as an Android programmer.

Of course, I started by reading a bit. Actually, I did that a few years ago, trying to figure out how Android worked and its security was organized. I did it some more specific reading, though, in the “Hello, world!” category, just to get started.

Then, I upgraded Eclipse on my home computer, got the STK, and started it. It works fairly well. In the first evening, I mostly learnt about what an Activity is and how to use it, and what I got was actually very close to my game’s main screen:


A simple screen layout in Android

That’s a nice result for an absolute beginner after 3 hours of work, and it motivated me to start designing the thing a bit better. One or two evenings later, I had a menu:


A small Android menu

Do the icons look familiar? If you own an Android phone, they should, since they all are default icons. I thought I would do my own icons, until I looked at Android’s Icon Design Guidelines. Now, that reminds you why real application development is team work. I can do a few things with The Gimp, but I know already that even a simple icon will take a lot of time.

The menu, though, took no time at all, at least as long as I didn’t try to put anything real behind it. The first thing I did was add a few options. That took me some time, but this is all XML-based, and it works really well. It actually took me more time to type the string constants than to write the class that make the options accessible to the rest of the code. However, I have to admit that, in order to achieve that, Google has been very useful, this time as a search engine, finding other people who had solved the same problems. One or two evenings, and here is what I got:


A list of options made with Android

The next challenge has been to organize my data. After hesitating a while, I skipped the database for now, because my data looked a bit trivial, and a database didn’t really seem like the right thing to use for this application. I may regret my decision, but at least, I tried to encapsulate things a little bit to make the pain acceptable. The next step, that I expected to be extremely simple, was to build a list in which each element was made of a checkbox and a name, to select the categories of images to be displayed, like this:


The groups of images

How do you specify this? In the simplest way possible: a list of hashmaps. More precisely, in Java, a List>. Not a big deal for a standard programmer, but quite a trauma for a Java Card guy: “You mean that every stupid list displayed requires a list of hashmaps? Okaaaayyyy”. I felt really old for a while, but I went over it.

This is basically where I stand today. My next challenge is to be able to figure out whether or not my checkboxes are checked, which seems like it is easy. My data structure just happens to be wrong, which will require a bit of refactoring. With the summer, the visitors on our beautiful Côte d’Azur, and the upcoming Bastille Day fireworks, this may take a while, though.

More impressions as an Android user in a few.

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *