Android 2.0 and WebKit

Google just released the latest version of the Android SDK, Android 2.0, which does most of what I need it to do. I noticed that so far the changes that Google has made to WebKit have not found their way back to the Android Open Source Project, which is disappointing, but overall it looks interesting.

Google has recently ripped out Gears and replaced it with proper HTML 5 support. This means that the Android 2.0 browser now supports HTML5 Video, Canvas, Geolocation and Database Storage. This is pretty huge for Android and for PhoneGap on this platform, since this allows for the write once run anywhere behaviour that we expect, without any weird gotchas.

Now, I’m going to talk about what is in WebView. For those of you who don’t know, WebView is the WebKit Java Component that PhoneGap, and all other WebKit-based Browsers use on the Android device to display web content. So far, I’ve tested Canvas, Geolocation, and HTML5 Database Support, and I’ve gotten some mixed results.

Canvas works right out of the box, while Geolocation seems to not work at all in the Emulator. Of course, I have to send it mock locations to get it to work, so I have no idea what this would be like on an actual phone. I can say the same thing with the video tag. There are issues with it not actually playing the video, BUT I think it’s the fact that the video is a higher resolution than what the Emulator can handle. We’ll know more once someone tries this on a Motorola Droid or other next-gen Android device.

The BIGGEST issue is with the Android Database Support. It’s there, but only on the Browser Application, where the settings can be properly setup. However, it’s not present on the WebView itself, where you have to set the Database Path and the the location for where the Database Files will be stored. Of course, we end up with this sort of awesomeness.


This is caused by the fact that for some reason we don’t have a way to set the size of the database locally, or the fact that we don’t have a way to handle when we do go over quota, or both, or neither. We don’t know because there’s no examples on the Internet at this point on how to fix this issue for Android. If you take the same code in WebKit Nightly, Safari or Midori or any other WebKit that supports HTML5 storage, it should work.

I’m hoping once the code drops for Eclair, I can look at the browser activity and find the place where it’s enabled. This should be rather trivial, but given the fact that this is bleeding edge stuff, I’m not suprised that WebView, something only used by developers, would be overlooked/not documented.

I hope to have more info on Android 2.0 soon, and we will be looking at dramatically changing PhoneGap for Android based on these change. In the meantime, feel free to download the Android 2.0 SDK and try it out for yourself.