Monday, February 28, 2011

Android logo and Alien Syndrome

During the first time I looked at the Android logo:
,
my immediate reaction was... Hmm, I have seen this font before.

Ah ah, I have seen that in Alien Syndrome... an old game which you try to shoot some enemies, pick up powers, save your comrades, exit the map, go to next level.



* * *

The newest Android 2.3 may rock. But my 2.2 phone has a lot to be desired... what? no default voice recorder app? what? you can't even organize your apps in folders in main menu? The Messaging app stink bad... what? don't even have an option to choose Contacts? (must use the editbox for autocomplete), what? no default text messages such as "see you in a few minutes"? Come on, basic phones can do better than that. The radio app quits immediately after showing a message saying need headphone, come on, i want it outloud. and the phone didn't provide a headphone (even a cheap one)

Tuesday, February 22, 2011

Making your Android App run on a real phone

I finally got an Android phone... a Comet.
I am still unwilling to pay for Data Plan. So insert your SIM card from your basic phone and voila you have Androids, but no web feature like navigator until I am willing to pay.

An Android without a real keyboard is pain to use. The virtual keys are too small to press! Someone should invent an input system to use the ENTIRE screen to write chars instead of fighting the little keys. Even this Swype thing is hard.

Ok ok, let's talk about putting an Android phone app you developed on the SDK (on Windows) to your device.

First, make sure you developed for the right version of Android. On the Phone. Home->Settings->About phone, check the "Android Version". Make sure your app's target is not higher.

Now, put the USB chord in. Does your computer recognize it? Good. But it may only treat it as another USB drive.

The goal here is make "adb" (in SDK\platform-tools) knows about the device, with the command "adb devices"

Many people on the web has problem making this happen, including me... Ideally, it should be less troublesome.

On the phone, you will need to enable USB Debugging.
Check the checkbox in Settings->Development->USB debugging

On your machine, you will need
1. Download Google USB Driver. (This should be straight-forward).
2. Install it. Now that can be tricky. You may need to manually use the Add Hardware Wizard in Control Panel to look for the driver. The goal is to make Device Manager knows about the phone. If it does, you will see Android Phone->Android Composite ADB Interface.

There may be a set of drivers right on the phone, you may need to use those. You may get a Yellow exclamation point (that may mean USB Debugging is not enabled on the phone)

3. Use "adb devices" to see if you can see the device. If Device Manager can see it but adb can't see it, try to kill adb first with "adb kill-server"

Once you are attached, you can use Eclipse to install your app, or use the command line "adb install path/to/your.apk" to install your app on your device!
"adb logcat" will tell you if you have any errors. Things may run perfectly on your emulator but you may still get a "Sorry! This app must close" error.

If you get a NullPointerException in the onCreate of your Activity on an innocent line: findById(R.id.yourcontrol), that may mean you need another layout xml file for lower resolution. Duplicate your layout file in layout-small folder in the "res" folder in your source.

Good Luck.

Monday, February 21, 2011

Android database

Android has SQLite3 built in. and its got a strange way to do JDBC-like database.

You need to implement the SQLiteOpenHelper to define your schema with CREATE statements in the onCreate on provide the destruction statements with onUpgrade. You then get the db instance with the getWritableDatabase()... and may call the methods to query.

Look at how they do query. Instead of SELECT statement, you do this:


public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)


Don't be surprised if you pass in a bunch of null, null and nulls. Ok, for those who prefers SELECT statement, you can do a rawQuery.

Instead of UPDATE statement, you do this:


public int update (String table, ContentValues values, String whereClause, String[] whereArgs)


Why abandon the goodness of tried and true SQL?

So this is a new approach to DB, different from JDBC... and SOMEBODY is going to say this is not cool an do XML wrapping on things!
* * *

Being to do little database in a device is pretty cool. You want to mess with little memory blocks instead?

Besides SQLite, you can also write files or deal with the memory card, or good old value pairs for preferences.

Whoa, their is an linux shell you can deal with directly: adb shell.
See here for glorious details.

Graphics, database... http calls, and even geomap are just the beginning. Still many interesting things on the Android... There are all kinds of sensors that takes programming to a new level of possibilities.

Thursday, February 17, 2011

HP and Palm RIP

HP bought Palm and going to move the WebOS to PCs. That's interesting. Details here.

Palm HAD the spotlight (about 10 years ago). I played with Palms... in fact, I owned THREE Palms. My first Palm (Palm Vx) was destroyed by water, second one is Palm Zire 72 (destroyed by screen crack),
and the third one Palm Tungsten E2 is not destroyed but the calibration is out of whack. These are decent devices, but you can't talk to somebody with it (not a phone) or surf the web or use it as a map. Yes there were Palm+Phone combos (the Treo) long ago but they didn't fly like the iPhone. They were just not quite sleek enough.

This webOs thing was the os for Palm Pre... Palm's last approach to grab some marketshare... unforutunately the sales number are disappointing. Now HP are you SURE that's a good buy? Everyone is just too happy with their iPhones (or their basic free phones) and won't even look at the Palm.

Good luck HP... it is competitive out there, and you will need A LOT of marketing to convince people your stuff is cool too.
Apple users are so loyal... they are not so likely to dump their cool iphones/ipads for your stuff unless your stuff is hugely better. Their screens are so crispy clear that you've got to beat first (probably not so possible).

Tuesday, February 15, 2011

Android Graph 2D with bells and whistles

I learned a few new (basic) things about Android programming.
1. They don't do dialog boxes with many controls, you need a new "Activity" to do that, and you can toss parameters around with an "Intent".

The config dialog


2. There are various kind of menus in Android, you launch menu with the menu button and can add your own menu items in bottom of screen (options menu).

Options menu for zooming




3. Now the ultimate bells-and-whistles for a graphing app: I can drag the graph around with a onTouchEvent. I bet your graphic calculator can't do that.

All these activities change the x and y range and will refresh the View within.

On Egypt

Egypt's revolution is remarkable... Oh, the dictator Mubarak gave up the dictatorship after protests. The people have won I suppose.
But does it end of all their woes? I am not so sure. Still rocky road ahead.

I have been living a rock, I have never even heard of Mubarak for the past 30 years. He doesn't come on headlines often like some dictators with nuclear weapons threatening neighbors. Egyptians ought to be happy their protest didn't end up like Tianenmen Square in 1989.

I only know Egypt has an ancient civilization. They have some great pyramids. There are the mummies and there are the Pharoah and there was incapability of drawing in 3D.

You may have heard about Egypt in the Bible.

Egypt is where the 11 bad brothers of Joseph go to when there was famine.
It is where Israelites get enslaved and God rescued them in Exodus.
God punished them with the horrible Ten Plagues.
The Red Sea opened and devoured the Egyptian soldiers. That's terrifying.
In NT, Gabriel the angel tell Mary and Joseph to go there to avoid the killing of the boys.

Egypt had all that idols and stuff that God didn't like.

Readers are supposed to go "yay! God has delivered His people from the slavery and idols"... so they deserved it. I wonder if Egyptians ever protest against that (probably not a good idea)

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...

Wednesday, February 2, 2011

Blizzard of 2011

The blizzard of 2011 is dumping some heavy snow.

The 1999 snow is worse? I beg to differ. Well the amount of snow you get depends on where you live. It is more than that 18 inch the weatherman says.

It has been a long while since I hear school closings, and office closings due to severe weather. It is good that modern day technology allows you to login to your computer even you're at home.

It will take entire neighborhood's effort to clear out the alley to get cars out... at least a couple weeks for lives to get back to normal. Many people will lose a lot of money in snow... such as that busy coffee shop.

Can someone give me an explanation why snow storms get so big?

Yea yea as a kid, I've heard water evaporate and become cloud (but why heavy rain cloud is black) and come back down as rain (but why sometimes so heavy than others?)

Tuesday, February 1, 2011

Julia on google map

The Google Research Blog has an article on the zoomable Julia fractal with the mapping API. Wow, this is cool.
This is some heavy duty number crunching.. and HTML5 canvas at work.

Fractals are complex equations in action...by iterating... gee, I have to look up my notes to remind myself what I once knew about it. Some people finds immense beauty.

Once upon a time I found code in Pascal that plots the Mandelbrot set and I converted it to java applet with zoom-able range.

HTML5 will be more relevant if IE adopts it, or the world dumps IE for FF and Chrome.