Monday, February 7, 2011

Android revisited

Phones... it's the platform of the future. Software developers ought to know a thing or two about programming the phone. Or maybe not. Modern phones can run webapps and perhaps all you need to know is html+javascript like programming a web app.

Now there are many phone platforms: iPhone, Android, Blackberry, and Windows Phone 7.

Well the biggest players are iPhone and Android. IPhone requires a Mac (which I don't have), and yikes, Objective C is ugly!

Android is open source java based, sounds good to me. Blackberry... seems to be not as dominant as the big 2. Microsoft phone.... I have not seen anyone using one, have you?

BTW, my favorite Microsoft writer Charles Petzold is giving away his Windows Phone 7 book for free.

I experimented with Android quite some time ago, and I was impressed with the sample apps that come with it. Ooh it can even do OpenGL 3D graphics (on a phone?!).

I decided to port an very old app that I did a decade+ ago in java applet into Android. My 2D function plotter. Given an edit box to type in f(x), such as f(x) = sin(x), provide a button to plot the graph!

Now, for a compiled language like Java, it may be harder than you think to turn a String of equation, such as 2*x+1 and sin(x)-cos(x), and plug some values in to evaluate. It requires a parser. A decade ago I got a parser from some C code I found and I ported it...

Eclipse is your friend. The plugin do a lot of work for you when you New->Android Application.

So... to create an android app with an UI is MUCH like a java applet, you put controls on a layout, either by "adding" or by the XML UI designer. For some strange reason, I can't get the custom graphic view to work right... so I am doing old fashion "add" to the layout.

And after some tweaking my app is running!


The Android API is nicely documented, but like any javadoc I'd like to see more runnable samples.

Android provides its own Log (not log4J), in its LogCat window in Eclipse, and System.out.println doesn't spit things out to the console. Unfortunately, Eclipse's LogCat window does not always work! The adb debugger works better.

The Android emulator is SLOW. Yawn.

To do:
add other fun things such as config dialog box or menus...
find out what else I can play with on Android...

No comments: