Java Development News:
Android: The Next Generation
By Barry Burd
13 Jul 2014 | TheServerSide.com
Google's annual developer conference, Google I/O, was held in San Francisco on June 25th and 26th. During the keynote address, Sundar Pichai, Google's Senior Vice President of Android, Chrome and Apps, introduced the newest version of Android, codenamed Android L. The L designation comes from Android's naming convention which started with Cupcake (C), then Donut (D), then Eclair (E), followed with various sweets up to the most recent version (KitKat, introduced in October 2013). Pichai called Android L "a radical approach" compared with previous Android update releases. During several breakout sessions, Google software engineers Chet Hasse, Dan Sandler, and Adam Powell, among others, revealed various details and features of Android L.
Android L and material design
The showpiece of Android L is material design. With material design, the developer imagines each element raised zero or more pixels above a mobile device's screen. This elevation from the screen is one of the element's properties, in addition to other properties such as background color, position, size, text, and so on. For example, to place a rectangle three pixels above the screen's surface, the developer simply writes:
Android uses the rectangle's elevation to create the impression of three dimensions with shadows that change in real-time, object tilting, surface rippling, and icons whose appearance is tied to their moment-by-moment state. To create a blue ripple effect over a green rectangle, you write
<ripple android:color="#ff00ff00"> <item android:drawable="#ff0000ff" /> <ripple />
Having created the ripple effect, you can take an element on the screen and make that effect be its background.
Android L and the recycler view
Another new Android L feature, the recycler view, promises vast improvements over Android's traditional list view. Like the list view, a recycler view displays items one after another, such as email addresses, contacts, books for sale, or other items. But the recycler view is easier to code. In addition, recycler view animates the insertion and removal of items, can scroll items horizontally (something lacking with the list view), and can be customized in many other ways.
The new card view presents items one on top of another the way Android's frame layout does in previous Android versions. But, unlike the frame layout, the new card view takes advantage of each item's elevation to display shadows and other effects that change dynamically.
Improved usability and flexibility
The animation options in Android L are more flexible than in previous Android releases. For example, you can specify the speed of an animation as points along a Bézier curve, or with the three pre-packaged options:
- @interpolator/fast_out_linear_in: Acccelerate at first, then move at a steady pace.
- @interpolator/fast_out_slow_in: Accelerate at first, then move at a steady pace, but then decelerate near the end of the animation.
- @interpolator/linear_out_slow_in: Move at a steady pace until near the end of the animation, then decelerate.
Android L includes new features for managing transitions between activities. (In Android, an
activity is one "screenful" of user interface. A typical app contains more than one
activity. For example, an online store's mobile app might contain an activity listing the items for
sale. When the user clicks on an item, a new activity containing details about that item takes over
the device's screen.) In Android L, you can fine-tune the transition from one activity to another.
In particular, you can describe the behavior of elements within the activity. In the online store
example, you can make the clicked item stay on the screen while the detail activity replaces the
list activity. You do this by adding options to a startActivity call:
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, androidRobotView, "robot"); startActivity(intent, options.toBundle());
(This sample code connects the "robot" element in one activity with the similarly named "robot" element in another activity. The result is a visual effect in which a single "robot" element stays on the screen during the transition to the new activity.) You can even animate an element as the surrounding activity changes.
During the conference, presenters emphasized that the visual enhancements in Android L aren't meant to create flashy-looking graphics. They reminded attendees that fancy-looking visual effects are no substitute for good planning and good design. The enhancements in Android L are meant to make the user experience clearer. The appearance of motion and the response to touch help the user understand where a graphical element came from and what that graphical element can do. The overall result is more effective use of the elements in an application.
In addition to the new visual tools, Android L includes many general enhancements:
- The new android.hardware.camera2 package gives the developer fine-grained control over the use of the device's camera. For example, you can split a scene into parts and assign different brightness/contrast settings for each part.
- The new audio buffering and encoding features provide better performance and smoother audio playback.
- Project Volta displays detailed battery information for the Android developer.
- Notifications have spheres of visibility. With the VISIBILITY_PUBLIC sphere, a notification appears whether the device's screen is locked or not. (There's no need to unlock the screen in order to see the notification.) With the VISIBILITY_PRIVATE sphere, a sanitized version of the notification appears when the device's screen is locked. With the VISIBILITY_SECRET sphere, nothing about the notification appears unless the device's screen is unlocked.
- The default runtime for an Android L application is ART, not Dalvik. The original Dalvik runtime was optimized for devices with slow processors and very little memory. The newer ART runtime makes use of today's device profiles with faster processors and more memory. In addition, ART includes full support for 64-bit processors. Apps running on ART have impressive performance characteristics over apps running on Dalvik.
Android L is available to developers in beta until the formal release in Fall 2014. Visit developer.android.com/preview for more details.
What is your favorite new Android L feature? Let us know.