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.

No comments:

Post a Comment