Android: Spin the Bottle!

Monday, February 16, 2009

Install on G1: Install on phone via Android Market. Spin the Bottle is listed in the Entertainment section.

Install on SDK emulator: Download the apk package and install it to the emulator with a command: “adb install SpinBottle.apk”

Our Spin the Bottle iPhone concept webapp has now been ported to Android and is available in the Android Market for free as a native Android application. You can install it to your G1 via the Android Market. Go get it and have fun.

10000 downloads in 44 hours

To my amazement, this tiny and somewhat useless app got downloaded 10000 times in just under 2 days. I think the figure is promising considering there really aren’t Android phones much anywhere. The market slice of Android is close to nothing. Currently Android is only sold at US and UK and we don’t know the exact sales numbers of phones.

If download numbers are now in the tens of thousands when there is just a single Android phone available, what happens to the numbers when Android phones start entering the market in force? As a
developer it surely is exciting to see the download numbers go up.

Porting

Porting Spin the Bottle from iPhone to Android was a fun exercise. Porting didn’t took too much effort since I’ve been following Android development and know the Android framework well. I think the
framework has all the big construction blocks in place and is a very promising modern application platform. The framework has innovations to make developer’s life easier.

Actually, codewise, we are not talking about a port from iPhone to Android. Since the iPhone was a webapp coded with XHTML/CSS/Javascript and running inside a browser, there doesn’t exist a direct landing path to Android native framework with Java and a new UI API. So the code portion was rewritten.

Graphics-wise the app is a port. The same .PNG image files are deployed in both iPhone and Android versions. The overall look and feel is also similar.

And yes, I did try to run the iPhone webapp directly in the Android web browser. Unfortunately the Android browser doesn’t yet quite match the iPhone browser which has advanced CSS animations. But you can bet Android browser will improve. (Rumors say Chrome is on the way to Android.) CSS animations are also in a standardization track and will appear in all modern browsers soon.

Android Goodies

Here’s a couple of tech goodies about Android that are in use in Spin the Bottle.

Embedded browser. An embedded web browser is an essential component in today’s applications not just because most of the data exists on the web but also because web allows you to easily present local rich text and media with a little bit of XHTML and CSS. The about screen in Spin the Bottle displays an embedded webkit browser in use. Constructing the about screen is much easier in XHTML than with native widgets. When the close button of the page is pressed, the event is communicated back to the native application via Javascript-Java-bridge.

Activities. Android tries not to be a monolith platform but an ecosystem of applications where applications can work together by offering services to each other via activities. Think of activity as an entry point to an application, like an URL to a site. An application can mix and match services of other applications by calling their activities instead of implementing all the functionality by itself. Spin the Bottle calls system “email send” activity when the “Email a friend” button is pressed.

Resource handling. Resource handling in Android is quite robust. Resources are external files like images, XML or HTML that are processed and packaged inside the app for easy consumption by the
app. The PNG bottle image files with alpha masks can be loaded with a single line of code.

Animations. Android has a good 2D animation framework. You can conveniently declare animations in XML files and attach them to any view and widget in your screen. Currently there are 4 types of animation available: alpha, transition, rotation and scale. Spin the Bottle uses transition animation when it slides the about box up from the bottom of the screen.

Landscape. The Android framework knows the properties and the present status of the device and can offer this info directly to your app without extra code. For example, Spin the Bottle defines two fluid layouts in XML, one for portrait and one for landscape mode. When the orientation changes, I don’t need to do anything in code, the Android framework just picks up the right XML based on the new orientation. Nice.

PS. The current download number stands at around 19000, one week after the launch. Users have rated the app with 3.77 out of 5. Thanks.

Tomi

3 Responses to “Android: Spin the Bottle!”

  1. mike says:

    thanks for the information. Will be very useful for those wanting the chance to win the Android Dev Phone 1 that is available at MobileDevCamp.fi (see here - http://mobiledevcamp.fi/2009/02/16/are-you-ready-for-the-challenge/ for more details)

  2. El juego de la botella en el móvil | Geekotic says:

    [...] cachondas con sus amigos alrededor de una diminuta pantalla aquellos que posean un móvil con Android, Symbian, o una vieja [...]

  3. Tester says:

    Are you willing to share your code ?

Leave a Reply