Friday, January 16, 2009

More Android? is it even possible



Apart from a most interesting trip to the ICA London last night for the Every Single One Of Us powwow I've spent a lot of the last week playing with balls!

I thought I'd set myself a little Christmas project this year; to create a Newton's Cradle app for the G1. I've had some maths lessons in my past so I figured it couldn't be that hard. I kicked off with the Lunar Lander demo to get a nicely set up canvas with physics run thread and worked from there. Unfortunately either my maths isn't as good as I suspected, or I never gave Newton all the credit he was due. Anyway, a few Sin, Cos, Tan's, circles and triangles later we have the Newton's Cradle app for the G1 in the Android Marketplace.

I've decided not to put code snippets in this time as again the entire source code is available here.

Monday, January 12, 2009

Playing with the Android source: Bookmarker



Since Christmas I've been wanting to achieve 2 small goals (1) get to grips with the Android OS Source code and (2) make another Android application.

As is usual with these things I've started but not finished 6 android apps, various things from a Newtons Cradle model to a Comic strip reader, the former sent me right back to maths class. The application that I decided to complete first was a tiny tool which allows you to re-order the bookmarks in an Android devices web browser.

So how do you go about replicating the bookmarks page of the web browser on Android? well it is pretty simple - you go to the Android source code at http://android.git.kernel.org/ and scroll down to platform/packages/apps/Browser.git where you are free to browse the source of the various branches of the android web browser from Release 1.0 upto and including the cupcake branch. Dig a little deeper and you end up at BrowserBookmarksPage.java. Now you can create a new project in eclispe download the appropriate source files (BrowserBookmarksAdapter.java is the key to it all) and marvel at how powerful open source operating systems really are.

Add a couple of buttons over the top of the ListView to enable moving, deleting and launching of the bookmarks and really it is a suprisingly quick and easy app to knock up. Although admittedly a little more attention could make it a lot prettier. You also need 2 permissions in the manifest file to get read/write access to the bookmarks
<uses-permission name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"></uses-permission>
<uses-permission name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"></uses-permission>

This time I have released the project source code on Google Code, the project is called AndroidBookmarker at http://androidbookmarker.googlecode.com/

On a side note if you have any experience modelling balls on peices of string then I'd like to talk to you, this Newtons Cradle app is doing my head in, angular velocities, gravity, momentum, agghhhhhh.