Android 4.1 (Jelly Bean) for Developers
For some, the Jelly Bean (Android 4.1) release at Google I/O was a surprise. As a minor point release from Ice Cream Sandwich (Android 4.0), there are not that many new features for developers, but there are a lot of user-level improvements from a performance perspective. Still, it's good to check what areas of the Android SDK were modified and make sure your apps will work as well or better than they did prior to the update.
(images © 2012 Google)
Project Butter Takes Center Stage
The Android team has been spending a lot of effort in recent releases to focus on improving the user experience across the platform. This means fewer new features, but improvements to existing features in terms of performance, responsiveness, reliability, and visual appeal. In many cases, app developers need not do much, if anything, to harness these new features, unlike some past updates like hardware acceleration, which may have required the developer to make minor tweaks and rebuild their apps.
The Jelly Bean release continues to focus on improving the user's experience with the platform. Nicknamed Project Butter, the Android platform has benefited from enhancements like these:
- Graphical timing improvements (put simply, much more of the system synchronized to the screen redraws)
- Predictive touch (instead of scrolling to where your finger was at a screen redraw, it scrolls to where it thinks your finger will be when the screen is actually displayed)
- Enhanced tools to find places in apps where improvements can be made (presumably, the Android team used these new tools on built-in apps to make them much smoother and more responsive, too)
Together, these improvements give users a fast, responsive, and buttery experience they expect from modern devices.
Many of the performance enhancements were applied across the platform and do not require developers to update their apps. That said, Google has made it clear that developers should not assume they can simply write an app, publish it, and forget about it.
They expect developers to be routinely and consistently updating their apps when new versions of the platform are released. In other words, they want third-party developer apps to be maintained and improved, and there are plenty of opportunities to do this with the new Jelly Bean release.
Do I Need to Update My Native Android Apps?
That's the real question you're asking yourself, right? Will I have to update my app? Will this release break my app? Usually, the answer is you don't have to update your apps unless you want to; the Android team tries to make new platform versions compatible with legacy apps (within reason).
That said, it's always a good idea to take advantage of this time before users get the new Jelly Bean release to ensure that your apps play nice on the updated platform.
Here are some areas to pay special attention to in your apps because the APIs have had some significant changes:
- If your app uses notifications, you should know that the notification bar and pane has been greatly improved for more feature-rich notifications. Check out the Notification.Builder class (android.app.Notification.Builder) for more details on how you can create different styles of notifications with multiple actions and different priorities. You can also include more complex controls like graphics and GridLayout in your notifications.
- If your app includes App Widgets, this area of the SDK has received improvements as well. New controls like GridLayout and ViewStub can now be used in App Widgets. App Widgets automatically resize themselves based on where they are placed. The App Widget host dictates the layout features of the App Widget, and can adjust content based on the size and orientation of the space available. See classes such as AppWidgetHostView (android.appwidget.AppWidgetHostView) for updates.
- If your app leveraged Google's Cloud-To-Device Messaging (C2DM) service, this service has been deprecated and you will need to migrate to the new Google Cloud Messaging (GCM) service. You can find out more about the GCM service here: http://developer.android.com/guide/google/gcm/index.html
- If your application leverages the Support Library (aka the Compatibility Package) for backwards compatibility, you should be aware that a new revision (Revision 9) was released in June along with the Jelly Bean SDK updates. Certain Jelly Bean features have been rolled into the package, along with many bug fixes to existing Support Library features.
- If your application uses Renderscript, you'll find new features in this area as well. You can also now debug your Renderscript scripts.
- If your application uses NFC (Android Beam), this technology was improved in Android 4.1 to allow for Bluetooth data transfer—a key feature that developers have been waiting for.
- If your application uses Wi-Fi APIs, there have been numerous improvements in this area as well. Android 4.1 includes both multicast DNS-based service discovery and improved support for Wi-Fi Direct pre-associated service discovery. These features greatly simplify Wi-Fi connectivity.
- If your app is composed of multiple Activity classes that the user transitions through, you will likely want to look into the improved navigation support added in Jelly Bean for handling "Up" navigation via a new XML attribute called android:parentActivityName. For a more general discussion of Back and Up navigation guidelines, see the Android Design website at http://developer.android.com/design/patterns/navigation.html
- If your app relies upon other input devices, it can register for connection events from, and query the capabilities of, input devices that are connected to the user's devices. This is particularly useful for games that support external game pads.
- If you use custom View controls in your app, this is always an area to review when new Android SDK versions are released. Jelly Bean includes numerous changes to the accessibility framework that impact View components, so you will want to review your custom View controls to make sure they jive with the improved accessibility framework features that will automatically be available in standard View controls.
- If your app is data-centric, you'll want to look at the improvements to the app network bandwidth management. Developers can now programmatically check whether or not the user is connected to a metered network with the isActiveNetworkMetered() method of the ConnectivityManager class before initiating data-intensive operations that might cost the user. Note that this feature has also been rolled into the latest Support Library for backwards compatibility.
- If your app has Live Wallpapers, there is an improved way to work with wallpaper previews. See the WallpaperManager class (android.app.WallpaperManager) for details.
- From a publishing perspective, the platform has improved internationalization support for non-Roman languages. If your app is appropriate for Arabic, Hebrew, and Asian audiences, you may want to review your UI and start selling to these locales. For example, users can now manipulate text in TextView and EditText controls bi-directionally (left-to-right or right-to-left) and the WebView has support for vertical text like Japanese. There is also support for custom keyboard maps for different types of international keyboards.
- If your app plays back audio that can benefit from multi-channel output, then it should be updated with the newly added support in Android 4.1 for 5.1 audio output (available on devices that support it). And you need not worry about hardware that doesn't support it; the output will be down-mixed as necessary. Several other audio enhancements are available that, in effect, make the audio experience more buttery. For example, finishing the playback of audio can trigger recording audio for seamless record prompting, audio files can be chained for seamless playback of linked tracks, and audio preprocessing is now available.
Do I Need to Update My Web Apps?
If you're using Flash in your web apps, it's time to either switch to a Flash-only solution using Adobe AIR or drop Flash completely in favor of other technologies like HTML5. Adobe has announced that it will not support the Flash browser plug-in on Android 4.1 and above. Note also that Chrome for Android does not support the Flash browser plug-in.