UPDATE: Google has just released an update to Android 4.0—the Ice Cream Sandwich release—before most devices ever received their first build. Google bumped the API Level up to 15 and called it 4.0.3.
This minor release has a short list of hidden gems inside it for developers in addition to what is found in the initial ICS release. At the top of that list are Intent selectors, which are designed to modify the types of applications an Intent will match without modifying the Intent contents themselves. Selectors are used to tell an Intent to match a specific system application, such as the Gallery, Browser, Calendar, Music, or Maps applications, regardless of what data contents the Intent includes. This allows developers to create direct requests to launch system applications without needing to rely on the implicit filtering behavior of Intent resolution.
For developers connecting their apps to other devices using Bluetooth, the long-awaited UUID discovery methods have been made public in API 15. Developers no longer need to use reflection or other crafty means to obtain the UUID of the service they want to connect with on a remote device in order to open the RFCOMM socket. Two new methods, fetchUuidsWithSdp() and getUuids(), are now available to start the discovery process and to monitor the results via Broadcast, or return the cached data from the last run discovery operation. This change goes a long way to making Android easier to use in working with a broad range of embedded Bluetooth devices.
Finally, the AOSP now includes a full complement of built-in device targets, including the Galaxy Nexus, Nexus S and Xoom tablet. Developers with one of these devices can build and run UserDebug versions of Android 4.0.3 on their development devices.
Android 4.0, codenamed Ice Cream Sandwich (ICS), brings to handsets all of the advances and enhancements introduced for tablets in the 3.x/Honeycomb releases, unifying all Android devices under a single set of developer APIs.
Since Honeycomb was only available on tablet devices, many developers may not even be aware of the features introduced to the platform at that time, and 4.0 may be your first introduction to many of these features. For this reason, we will point out several of the key Honeycomb features that you can now use on all Android devices.
ICS also brings with it a set of new features that developers will be interested in. This article will look at some of the most important changes you should have your eye on.
With Ice Cream Sandwich, the latest Android source will once again be visible to the public, and the shepherds of the Android open-source project (AOSP) have promised that the GitWeb interface will return soon. This is fantastic news as we developers can finally get a glimpse at much of the Honeycomb additions (like Fragments) that were previously hidden, as well as all the new APIs that ICS has to offer. (ICS is available now to developers in the SDK and will soon be available on devices.)
As a developer, if you aren’t spending time with the AOSP code on a regular basis, you’re doing yourself a disservice. There is much to be learned from the source of the core system applications as well as the APIs that can greatly supplement the documentation in your knowledge of Android development.
The user interface
Many developers will soon be able to abandon using the v4 version of the Android Compatibility Library. Fragments and Loaders, which together represent the future of how Android UI and data synchronization will be built, are now available to handsets in ICS without the use of an external library. Developers may still find the v13 version of the Compatibility Library useful as it provides access to classes like ViewPager that are not available in any version of the core SDK.
A personal favorite of mine from Honeycomb is the new Property Animation system. If I may gush a little, this is the way an animation system should work, and it will be a great service to developers to be able to use this API on all Android devices. The new API makes use of classes like ValueAnimator, ObjectAnimator and ViewPropertyAnimator to provide time-interpolated values for just about any value you can imagine.
ViewPropertyAnimator allows developers to finally animate properties on View objects themselves, instead of simply manipulating the drawing code used to display the View onscreen. This is the cure for the common problem of animating a View (such as a Button) to a new location, and no longer being able to interact with it because the animation did not change the View bounds, just the location where it is drawn.
Along with the new animation system, Renderscript is making its debut into the handset world with ICS. Another advancement originally introduced in Honeycomb, Renderscript provides two high-performance libraries for developers to do graphics and computation. These two libraries, aptly named Graphics and Compute, provide a solid alternative to doing many operations that would otherwise require the Native Development Kit (NDK) to gain similar performance, but without the required complexity of fully native code.
New for ICS, the GridLayout widget provides a boost for application layouts. GridLayout is a very flexible container aimed at replacing areas in applications where multiple layouts are nested in order to obtain the desired orientations and spacing. This flattening of the view hierarchy will help developers create more complex interfaces that still perform well on all devices.
GridLayout is also tightly coupled with the latest Eclipse plug-in, Android Developer Tools visual layout editor, which allows for one of the first truly freeform designing experiences inside of this tool. GridLayout is flexible enough to replace almost any nested layout in current applications, and general enough that it will undoubtedly become the default layout for many developers in their future applications.
New providers
In Android 4.0, the Calendar API has finally been made public. Developers wishing to add calendar functionality to their apps will no longer need to peruse the AOSP Calendar application to hunt for valid Intent and Content Uniform Resource Identifier strings to hard-code, only to realize they don’t universally work or they break in later releases. Instead, we can now use official Intents to add or edit calendar events, as well as access the underlying content provider directly via CalendarContract.
A brand new provider was released to enable applications that want to integrate with the device’s voicemail system. The VoicemailContract provides access to the device’s content provider responsible for storing voicemail data. From the extended set of Broadcast Intents provided with this API, it is apparent that the intended purpose is for applications that wish to contribute to the unified store (named a “voicemail source” application) rather than those simply interested in reading data about existing voicemail information—although that will be possible.
Another very common developer function that ICS is helping to streamline is adding sharing from an application via the generic ACTION_SEND Intent. This feature gets some assistance via ShareActionProvider. This new widget assists with placing the share method into your UI, as well as displaying the selection dialog of which apps to share the specified content through. There are even a few added bonus features, such as tracking the history of previous share actions. ShareActionProvider is built out of the new abstract ActionProvider, so developers can extend this same concept for other uses as well.
Expanded connectivity
ICS also marks the first appearance of the official Android USB device and accessory APIs on handsets. Although many handsets running 2.3.4 or later were lucky enough to get a back-ported version of the official USB library via the com.android.future.usb package as part of the Google APIs add-on, the official android.hardware.usb package that initially appeared in Android 3.1 will now be available on handsets.
The Bluetooth profile support for Headsets and Advanced Audio Distribution Profile that was introduced in Honeycomb is now available in 4.0. In addition, the array of supported profiles has expanded to include the Health Device Profile. This means that developers can now write applications to implement the IEEE 11073 protocol, and interact with wireless medical devices such as weight scales, blood pressure monitors and blood glucose meters.
Point-to-point (P2P) connections over Wi-Fi using Wi-Fi Direct are also now supported. Developers can use this technology to make high-bandwidth, direct connections between Android devices, or from an Android device to a wireless peripheral (like a printer) without the requirement of a Wi-Fi infrastructure in place. Many P2P applications making use of the existing Bluetooth RFCOMM APIs to transfer data between devices will be able to use this technology instead to transfer data more efficiently.
Media additions
With each new Android release, the list of supported media formats expands, and the 4.0 release is no exception. In addition to new containers like V8 and WebP, the most notable addition is the HTTP Live Streaming (HLS) protocol, and the fact that both live and progressive streams are now supported over HTTPS on handset devices. Although HLS support was originally introduced in Honeycomb, ICS advances that support to version 3 of the protocol draft.
ICS includes a series of new features to apply effects, enhancements and transformations to audio, video, and images using OpenGL and Renderscript. This support is built atop the hardware-accelerated drawing support introduced in Honeycomb to provide maximum performance. A new package—android.media.effect—is dedicated to transformations such as red-eye correction, cropping and fisheye that developers can apply to images or frames.
Most Android developers depend on SurfaceView at one point or another to efficiently draw content from sources like the Camera or MediaPlayer, and ICS makes this experience even better with the introduction of TextureView. TextureView can be used just about anywhere you have a SurfaceView, and it behaves more like a proper View, allowing animations and transformations to be seamlessly applied. TextureView also allows for the capturing of the current frame as a bitmap image, something many developers (including myself) have grumbled about missing from SurfaceView for some time.
One of the great new user features is the ability to unlock the phone just by showing it your face. Accompanying the new Face Unlock feature that users will enjoy is a simple-to-use face detection API added to the Camera, allowing applications to obtain updates from the preview frames about any faces detected via a FaceDetectionListener.
At Google I/O this last May, Hugo Barra stood up on stage and promised all the developers watching that Google was working together with its partners to develop guidelines around the release of new Android versions out to consumer devices, hopefully to accelerate the process.
Ice Cream Sandwich brings some great things to the table for both users and developers, and what I have discussed here is only a fraction of the 282 classes and interfaces that were either added or changed. As consumers, we can only hope that the fruits of that promise come to bear, beginning with Ice Cream Sandwich.
Dave Smith is the lead engineer for mobile and embedded development at Xcellent Creations in Denver. You can follow him on Twitter (@devunwired) or visit his blog.