Android 2.2 Froyo browser: HTML5, accelerometer, Flash Player 10.1 and more

Android 2.2 (also known as Froyo) is now with us. Every Nexus One received the update before July, 4th and other models will have the update very soon. Also, many new devices (like Motorola Droid 2) will come with Android 2.2 very soon.

Unfortunately, the Android team has zero documentation, posts or information about browser compatibility. For this new version, it was not an exception.

The promises

In the last Google IO, there was a great Keynote about Android 2.2 new browser features (see video1 -starting at 6:00- and video2). I’ve to admit that I was pretty excited about this new APIs that could be available to web developers. The promises (and the demos shown) were:

  • Access to magnetometer and accelerometer
  • Access to camera
  • Access to API for voice recognition and speech
  • Flash Player 10.1 and Adobe AIR 2.0 support

The testing

So, after having the final 2.2 Android OS version on my Nexus One, I’ve started some tests and here is what I’ve found:

  • JavaScript performance was announced to be 2x-3x faster than before thanks to the new V8 JavaScript engine. It seems faster, yes.
  • JavaScript code runs on background when you switch to other browser tab, like in iOS 4.
  • Android browser now supports File Upload. As I mention in Chapter 6, Android -as iOS and webOS- did not understand <input type=”file” />. When you click “Choose File” you will get a popup menu with options to: select a file from the Gallery, from the music collection or from the sound recorder, where you can create an on-the-fly audio to upload. I’ve also an option “Documents to Go” that allows me to select any file on the SD card. I’m not sure why “Documents to Go” (an application available in Android Market) is listed here and if we can add more applications to this list (maybe using some Intention).
  • Android browser still does NOT support Animated GIF nor SVG. I’ve found an official response about SVG: We have chosen intentionally to not support SVG in the browser to save space; full SVG adds over 1M to the webkit image size.”
  • Flash Player 10.1 works really great. There are some bugs and problems with some Flash-enabled websites, but I’ve tried many different websites and Flash is working good and surprisingly fast. You can press-and-hold the Flash movie to get a full-screen button for that particular movie. You have to use the back button to return from full-screen mode.
  • I’ve been in AIR for Android Prerelease program, but I couldn’t install it yet on my device, so I don’t have an opinion yet.
  • Now it appears to have a little support for the HTML5′s video tag, but my tests indicate that only work if we provide JavaScript controls to play and stop and it doesn’t work so well.
  • I could not find any online reference, documentation or sample about those new APIs announced for accelerometer, camera, etc. So, I created a JavaScript object browser (available at mobilexweb.com/tests/object or typing ad.ag/gtwjmg in your mobile browser (that is a Mobile Tiny URL).

New APIs

Looking for any new API to access the promised features, I’ve found some new APIs:

  • There is a property to query about the current connection type: navigator.connection.type. There is also a navigator.connection enumeration, having the possible values: UNKNOWN, ETHERNET, WIFI, CELL_2G, CELL_3G. And IT WORKS! Then, you can decide what to do depending on the user’s connection:
    if (navigator.connection.type==navigator.connection.WIFI) { }
  • The boolean navigator.onLine can be used to know if the device is connected or not to the web (remember that with HTML 5 we can make an offline webapp, see Chapters 9 and 12). Events like ononline and onoffline are working fine to detect changes in the connection (even when we change from 3G to WIFI, the online event is fired).
  • If we use the W3C’s Geolocation API (as we’ve seen in Chapter 11), the position object received has a coord.heading property that I supposed that can be the way to access the magnetometer information. But that property has always “null”.
  • I have found navigator.isApplicationInstalled(app_name, callback) that it is supposed to look for a native application installed on the device. I’ve tried several ways to query and I always get a false parameter in the callback. I’ve found this API implemented in the WebKit open source project, but no sample or information about it. It could be great if it works. As I mention in Chapter 6, using Intention URI-schemes you can call a native application from the browser in Android (in iOS too), but you don’t know if the app is installed or not.
  • I have also found navigator.registerProtocolHandler(scheme, url, title) and navigator.registerContentHandler(mime_type, url, title). I’ve executed them but nothing happens and appears to not being working. The WebKit open source project C++ code seems to work, but nothing happens in the final browser. These are APIs from the Web Application specification and could be great, if working. We can then register our web application to be default handler for a MIME type (for example, the browser could open our website when the user clicks on a DOC file) or for a protocol (the WebKit C++ code says that we can apply for a handler of any protocol different to http, https or file).

What about the promises? I couldn’t find any new API for those features. I have still hope that a hidden API is available but, if not, maybe the solution can be going through a Flash Player movie (I’m working on testing this for a future post). I’m happy with some of the new features in Froyo, but I’m still unhappy for not having official documentation about browser features. Android team, it’s time to work on it!

If anyone found any other APIs or new features, feel free to add it here or contact me by twitter.

Share

Tags: , , , , ,

Comments, ideas, questions?

Loading Facebook Comments ...
  1. #1 written by Jason Grigsby July 9th, 2010 at 20:06

    The new APIs for device attributes are promised in the next version of Android (Gingerbread) due out late Fall.

    RE Q
  2. #2 written by firt July 10th, 2010 at 21:16

    Thanks Jason for the update. I don’t believe that Gingerbread will be with us late Fall. I hope to, but it’s too soon from this update. I believe, both Apple and Google wants one big update per year to simplify the process, the advertisement and event, in the Android world, the ability for manufacturers to prepare OS updated for its devices.

    RE Q
  3. #3 written by Jason Grigsby July 12th, 2010 at 23:35

    Why do you believe Google wants one update per year? That flies in the face of history and their stated positions.

    My late fall prediction is based on Google’s own comments about Gingerbread landing in Q4 2010 at Google I/O during the WebM announcement and FAQs:
    http://www.webmproject.org/about/faq/

    “When will other Google products support WebM and VP8?

    WebM support in Android is expected in the Gingerbread release (currently planned for Q4, 2010). ”

    There are bunch of articles projecting it for Q4 this year:
    http://www.google.com/search?q=android+gingerbread+release+date

    Most recently, the rumored date is October which is earlier than I expected.

    RE Q
  4. #4 written by firt July 13th, 2010 at 16:53

    Maybe this one update per year can be effective after Gingerbread. I was talking about big updates. I believe that after some talks with manufacturers. They made some kind of complaint to Google that they need to slow down big updates to reduce fragmentation and customer high expectations. I mean, every Android user today wants 2.2 update and some manufacturers (like Motorola) have just update to 2.1. However, I can be wrong.

    RE Q
  5. #5 written by Jamie October 18th, 2010 at 17:22

    “Flash Player 10.1 works really great. There are some bugs and problems…”

    You have a strange definition of “really great”. :-)

    RE Q
  6. #6 written by Simon MacDonald May 5th, 2011 at 20:09

    Hey,

    I only have a 2.1 device but on the 2.2 and 2.3 emulators the value of navigator.connection.type is always 0. Have you been able to test it on a real device? Does the value update properly?

    Simon

    RE Q
  7. #7 written by firt May 5th, 2011 at 20:15

    It worked on two devices I’ve tested

    RE Q
  8. #8 written by Simon MacDonald May 6th, 2011 at 13:57

    Thanks for letting me know. I just added this functionality to PhoneGap Android for phones running 1.5, 1.6 and 2.1. Good to hear it works for 2.2+.

    RE Q
  9. #9 written by KGuo August 4th, 2011 at 13:50

    Do you know whether there is any js API available for user to invoke some local application like email, map, etc.

    RE Q
  10. #10 written by firt August 4th, 2011 at 17:18

    Kevin, if you are creating a browser-based experience you can use data-URI schemes for opening native apps on Android and other platforms. If you are using a hybrid (PhoneGap, etc.) then you can use a JavaScript bridge to do that.

    RE Q

SetPageWidth