Now in Android: January 8, 2020

New Room and KTX docs, AndroidX releases, a new Room article, a new codelab, videos from recent conferences, and ADB podcast episodes

Chet Haase
Android Developers
6 min readJan 9, 2020

--

Illustration by Virginia Poltrack

Welcome to Now in Android, your ongoing guide to what’s new and notable in the world of Android development.

Hey everyone, welcome back from the holidays! It’s been a quiet time since the last Now in Android, as many of us were more consumed with holiday bites than software bytes. But a few things happened recently that are worth checking up on as our brains collectively page in the new year and we all try to answer the same question: What was that thing we were doing when we last closed our laptops?

Now in Android: The Video

Now in Android is now available in video (and podcast) form. Same content, but less reading required.

Now that the New in Android series is a regular thing, I wanted to make it available in other formats. Feel free to watch the video version here (or on the YouTube playlist) or to ignore it completely and get on with reading the article.

Roomful of documentation

Relationships are one of the hardest things to manage in life. Wouldn’t it be great if there was some clear documentation for making them work?

Tech writer Alex Cook has improved the situation by providing a new guide on Room entity relationships. @Florina covered some of this material in a recent article, but now all of the relationship information is in one place on our core documentation site.

Relationships: We can’t fix them, but we can make them easier to understand… for Room.

Another Room guide Alex provided recently is Prepopulate your Room database. In version 2.2, released last October, Room provided the capability to pre-initialize your app’s database on startup from a file on the local device. This new guide tells you how to use that feature.

KTX extensions

Android KTX provides Kotlin extension functions for existing classes, to simplify using Android APIs. Think of them as a way to improve the APIs in our world of backward compatibility, where we can’t change the core APIs themselves because that would break apps. In addition to more elegant, simpler APIs, they take advantage of key Kotlin features like lambdas, named and default parameters, coroutines, and (yes) extension functions to make the APIs even better and to integrate easily into your Kotlin development flow.

But the problem is: how do you find out what extension functions exist?

Previously, in order to find reference docs for a particular extension function, you had to know what you were looking for, in order to pull up the appropriate package reference which housed the extension docs. It’s like having the keys for your car, but not knowing what area you parked it in — or what city. It’ll be fine once you get there, but finding it can be… tricky.

All packages with KTX extensions in one easy table of contents

Joshua Baxter on the docs team has provided a solution: the List of KTX extensions page. Here you’ll find all of the extensions that KTX offers, handily referenced by content sections on the right-hand side of the doc. The doc contains links to the actual declaration of the extension function (which may have more information on it, such as sample code), as well as links to the class that is being extended.

Now you can more easily browse or find a particular extension, or the set of extensions for a particular class. Note that this doc also includes information about other KTX libraries beyond AndroidX. Both Firebase and Play Core have KTX extension functions that are worth checking out.

AndroidX Libraries

A few new AndroidX library versions were released in mid-December. First, there were some existing libraries that went stable:

  • Biometric 1.0.1: This library helps you use biometric authentication, without worrying about the changes to the underlying authentication platform APIs over the past few releases. This latest version is mostly bug fixes.
  • Browser 1.2.0: 1.2.0 introduces Dark Theme and Trusted Web Activities.
  • Enterprise 1.0.0: The enterprise feedback APIs have now hit stable with their first version.
  • Paging 2.1.1: The paging library simplifies gradual data loading with RecyclerView. This release has minor feature improvements over the previous one.
  • Room 2.2.3: The room library creates a powerful abstraction and APIs on top of SQLite. Version 2.2.3 is a minor bugfix release.

There were also a few libraries that released alpha versions. In particular, note a new library that had its first alpha release (so maybe not ready for prime time yet, but interesting to try out if you’ve been wanting this functionality):

Article: Observing Room databases with Flow

In version 2.2.0, Room added the capability of using Kotlin’s Flow API to be able to observe changes in your database. Florina Muntenescu posted Room 🔗 Flow, showing how to make it happen.

Codelab: Advanced Coroutines with Kotlin Flow and LiveData

Tiem Song and Sean McQuillan created this codelab for the Kotlin in Android workshop at KotlinConf, to show how to use LiveData with Coroutines, as well as Kotlin’s new Flow API. Work through the codelab for the full experience, or dive directly into the code if you prefer.

Conference Videos

One of the great things about conference events today, compared to a few years ago, is that the sessions are generally recorded and posted for public viewing.

I still find going to a conference in person to be worthwhile, because of that feeling of soaking in the content for a day or more, but also because I get to talk to everyone else that’s there. But it’s not physically possible to get to all of the conferences I’d like to attend, nor is it possible to even watch all of the content live at a multi-track event I did get to attend. It’s awesome to have the sessions available online soon after these events, so that I can catch up on all of the stuff I missed (at 1.5x speed!).

Two recent events have posted their videos recently:

Droidcon SF

Droidcon San Francisco took place in the last week of November, with deep Android content ranging from UI to dependency injection to tools to Kotlin to… many other topics.

Kotlinconf Videos

KotlinConf happened in early December in balmy Copenhagen. There were many sessions on Android, as well as on Kotlin overall (including language features and multi-platform).

ADB Podcast

There have been a couple of episodes of Android Developers Backstage posted since the last Now in Android. Check them out at the links below, or in your favorite podcast client:

ADB 129: Display, Input, and Haptics

Michael, Chet, and Romain (not in a pub)

In this episode, Chet and Romain travel all the way to London to have a chat with Michael Wright. This is not Michael’s first time on the podcast and once again the discussion is about displays, input devices and haptics.

ADB 130: First Law of Motion… Layout

In this episode, Tor, Romain and Chet chit chat with Nicolas Roard and John Hoford from the Android Studio team about Motion Layout — and ConstraintLayout and visual editing in the IDE.

Now then…

That’s it for this time. Go check out the new Room Relationships, Room Prepopulation, and KTX docs! Play with the new AndroidX releases! Read about observing database changes with Room and Flow! Crank up the IDE and dig into a LiveData/coroutines codelab! Pop a lot of corn and watch many, many session videos from Droidcon SF and KotlinConf! Go listen to the ADB podcast! And come back here soon for the next update from the Android developer universe.

--

--

Chet Haase
Android Developers

Past: Android development Present: Student, comedy writer Future: ???