Now in Android #16
AndroidX releases, articles and videos, codelabs and samples, and ADB podcast episodes
Welcome to Now in Android, your ongoing guide to what’s new and notable in the world of Android development.
As usual, there were many AndroidX libraries released recently. This included new stable releases with bugfixes:
There were also a veritable plethora of RC, beta, and alpha versions. I’d like to call out just a couple of the new alphas, related to animation. First is the back-port of the Animator APIs as part of Core-Animation 1.0.0-alpha01 as well as the new Vectordrawable-Seekable 1.0.0-alpha01.
You might wonder why we unbundled the Animator API. After all, those APIs have been in the platform for longer than the releases your app probably supports at this point (most of them were released in Android Honeycomb, 3.0–3.2). The answer lies in the other library: Vectordrawable-Seekable.
One of the oft-requested features for AnimatedVectorDrawable objects was the ability to make them “seekable” — to be able to pause and resume them, and to set their animation position programmatically, instead of just the original fire-and-forget functionality. The problem was that this capability depended upon platform capability for pausing and seeking their underlying animators, which wasn’t added until much later than the original Honeycomb-era APIs.
So in order to be able to seek/pause/resume AnimatedVectorDrawable objects (especially in the AndroidX unbundled libraries, across older releases), we needed to back-port the Animator APIs to pick up all of the right functionality and fixes.
Seek and ye shall find [animation]
NiA16 in Video and Podcast Form
This Now in Android is also offered in video and podcast form. It’s the same content, but with less reading required. The article version (keep reading!) is still the place to come for links to all of the content that’s covered.
Click on the link below, or just subscribe to the podcast in your favorite client app.
With this new tool, you can now see what’s going on in your app’s SQLite database (whether you are using SQLite directly or via the Room persistence library). You can make changes to the data directly in the tool. You can also see live updates to the data in the tool, or see the tool’s updates to the data in the app if you’re using Room and observing changes.
Meghan Mehta posted an article in the Kotlin Vocabulary series on operator overloading. Kotlin allows you to overload standard operators like +, -, and * or even access and comparison operators like  and <. Operator overloading can make your code more readable when performing standard operations on types that otherwise would not be able to use these operators directly. For example adding two Point objects or multiplying two Matrix objects looks natural and more concise with overloaded operators.
The article covers the basics of how to use this feature, as well as pointing out why you might not want to in some situations. Like the other Kotlin Vocabulary pieces, there’s also a description of how it all works under the hood.
Material Design Components
Nick Rout posted Migrating to Material Components for Android, which talks about the changes in the new Material Design Components 1.1.0 library, along with how to migrate from earlier versions of MDC and the much earlier Design Support Library. Pro tip if you are still using the Design Support library: First migrate to MDC 1.0.0 (which is compatible with AndroidX), then migrate up to 1.1.0.
Some of the new features in 1.1.0 include dark theme, full Material Theming support for color, typography, and shape, new widgets like the extended FAB and date picker, and various accessibility improvements and bug fixes.
It’s a long article with lots of details, links, and samples; check it out to get the most out of your migration to MDC.
Migrating to Material Components for Android
From Design Support Library 👉 MDC 1.0.0 👉 MDC 1.1.0 and beyond
Nick also posted a video version of this content:
Sean McQuillan posted an article that explains how to use the new One Tap API for authenticating users in your application. Authentication can be a crucial experience to optimize in order to avoid losing your users if they’re frustrated with the sign-up or sign-in process.
One Tap is part of a broader suite of authentication libraries offered as part of Google Identity Services. That suite is still in development and will be adding more features later, but for now you can use One Tap to create an easy flow for sign-up or sign-in. Stay tuned for more functionality later.
One Tap sign in for Android apps
The new One Tap sign-in and sign-up on Android helps you optimize the flow for authenticating users in your app. For…
Part 1: One-shot Operations explains how to use the LiveData coroutine builder KTX extension function to save on boilerplate code.
Part 2: Parameters with SwitchMap builds on the previous example, showing how to pass parameters with dynamic data as well.
Location, Location, Location
One of the biggest ongoing changes in the platform in recent releases has been around location, as we make it clearer to the user which apps are using location information and how they can control that use.
Jeremy Walker has rewritten the Android Location codelab to include more detailed instructions on using location, including best practices for the new policy changes, and more importantly, support for the new Android 11 restrictions.
Receive location updates in Android with Kotlin
Android 10 and 11 gives users more control over apps' access to device location. When an app running on Android 11…
The codelab covers the most common use case: retrieving location while the app is being actively used (while your activity is viewable or running as a foreground service with a Notification).
You may also notice that the codelab no longer includes retrieving location from the background. This behavior is not recommended unless you have a valid use case. If you do have such a use case in mind, there is also a new background location sample to check out. It follows the latest best practices for location policy.
Demonstrates retrieving location updates in the background. This app allows a user to receive location updates in the…
Shailen Tuli created a couple of codelabs to help developers implement accessible applications.
It turns out that most accessibility issues are taken care of for you by the Android libraries (especially when using standard widgets, as opposed to custom views). But even when there are problems, they tend to be relatively easy to fix; the trick is knowing how to find the problems so that you can fix them. The first codelab helps identify common problems in applications, as well as easy fixes for those problems.
Starting Android Accessibility
Android apps should be usable by everyone, including people with accessibility needs. Common conditions that affect a…
Once you’ve implemented an accessible application (which everyone should!), you’ll probably want to add some automated testing, to make sure that any future changes to that app continue to maintain the high level of accessibility that you built in from the start. Shailen’s next codelab covers some of the tools to use, and how you can integrate accessibility testing into your existing Espresso tests.
ADB Podcast Episodes
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 137: Accessibility
Speaking of accessibility (which I just was — see the two codelabs in the Samples section above!), Tor Norbye, Romain Guy and I had a conversation with Qasid Sadiq and Sally Yuen on the Android Accessibility team, talking about how developers can make their apps more accessible and usable by more people.
Episode 137: Accessibility
In this episode, Romain, Chet and Tor talked (remotely!) with Sally Yuen and Qasid Sadiq from the Accessibility team…
Episode 136: Remoting
This episode was a departure from our normal theme of talking to engineers about the tech they work on, and was instead a conversation between Tor, Romain and I about how we have all [mostly] adjusted to the new work-from-home reality.
Episode 136: Remoting
In this episode, Romain, Chet and Tor chat with zero guests about the current work-from-home reality, and about…
That’s it for this time. Go get the newest AndroidX library releases! Read the latest articles on Android development techniques! Play with a location or accessibility codelab, or a sample on location access! Listen to the latest ADB podcast episodes! And come back here soon for the next update from the Android developer universe.