December’s update to the Android support library includes better focusing when using DPADs in RecyclerViews and adds a
leanback.media package with helper classes for Android TV media players.
The support library has quickly become an important tool for developers. It adds in a variety of APIs that can be used on many API levels without requiring an update to the underlying operating system. Therefore, users can get a lot of features in apps without needing the latest OS version. Developers can import it with a single line in their gradle file and quickly get started with these tools.
In the latest update, version 25.1.0, there are a number of changes. Some of them are general, like specifying the number of items to fetch in a RecyclerView. There are also changes that may be more specific to Android TV, and those are the ones we’ll focus on.
Added focus recovery mechanism to RecyclerView. This also fixed support pref fragments broken focus when using DPAD navigation such as on Android TV devices.
The RecyclerView is a simple, cross-platform presenter which allows developers to display an indefinite amount of content in a scrolling view. With this recent change, focusing is now improved. This should make it easier to place these into apps and have the same layout work on a phone or TV.
The new package
android.support.v17.leanback.media contains a number of useful classes for building media player UI. The
PlaybackGlueHost allow developers to build activities that play media and show playback controls so users can have greater control over how they watch the content.
There is also a new package for processing images. The ExifSupportLibrary can read JPEG or RAW image formats and parse metadata. Exif data can be optionally added to these photos to provide greater context. It may include the photo’s geolocation, the camera and aperture used, or other things.
With this library, all of the specific nuances between these formats, and the subformats, are handled automatically. It’s now easy to read the metadata and use it in an app, or set the data to something else.
If you haven’t taken a look at the support library yet, this may be a good opportunity to do it. The APIs are well-tested and update frequently to support most phones. You can learn more on the Android Developers page.