Friday, November 26, 2010

Libraries

Android Library
Goal: To create an Android application that essentially serves as a base application. It contains default values, it creates a standard database, it contains standard activities. Child applications will use the base application as is, only overriding strings and display settings. Finally, since I am still rocking a G1, it has to be built on 1.6.
1) As it happens, library applications are supported on Android 1.6, but you must be upgraded to release 3 in order to make that work. I fought with that one for about an hour before thinking to check the versions on my SDK. That’s an hour of creative swear words that I’ll never get back.
2) Create the base application, and make sure it runs. Check.
3) In Eclipse, go in to the project properties, select Android, and check the “library” checkbox. Run the application again, and make sure it still works. I’m pretty sure it worked, but I’ve had a glass or two of wine, so let’s try again just to be sure. Yup, we’re good.
4) Create the first extension application, under properties, select Android, and choose the library option and add the base application. Launch the application. Expected behavior would be to launch the default activity, but override the application string name. Could it be that easy? Of course not. From this point, open the AndroidManifest.xml for the child application. Under the element that points to the activity in the library application, add




From this point, I have my application launching the Activity from my library application, but using the string resources from my child application.

Now, back to XML and SQLite.

so here we go

I'm a C# developer who has had an interest in Android almost since the beginning, but I finally jumped on board as a consumer almost 2 years ago when I got my hands on a G1. From there I tossed around the idea of developing for it, but I didn't actually start until I got stuck doing a Blackberry project for work. That got me motivated to crack open the Android SDK at home, and actually write some code. I'm new to Android, and new to Java, so I imagine much of what I write about will be obvious to people who actually know what they're doing. That's ok. I'm fine with that.