Illustration by Virginia Poltrack

Now in Android #25

Android 11 released, Jetpack DataStore, privacy changes, Android GPU Inspector, and podcast episodes

Chet Haase
Sep 16, 2020 · 5 min read

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

NiA25 in Video and Podcast Form

Video

Podcast

Android 11: It’s Here!

After months of preview and beta releases, we made it: Android 11 is officially launched, with the source code pushed to the Android Open Source Project (AOSP).

I’ve talked about the features in this release for developers and users already, but here are a few teasers and reminders:

  • UI improvements, including Conversations in the notifications panel, Bubbles, and synchronized IME animations.
  • Easy access to controls for connected devices and media.
  • Privacy enhancements like one-time and auto-reset permissions, scoped storage improvements, background location, and biometric strength APIs (with additions to the new Jetpack biometrics library for earlier releases).
  • Developer enhancements like the new exit reasons API, behavior toggling in the Developer Options panel, ADB incremental installation, and more Kotlin nullability annotations for platform APIs.

We’ve also made more strides in the Google Play system updates (originally called “mainline” for anyone like me that’s confused by naming changes), to provide support for more modules so that we can enable more frequent updates for core system functionality across the ecosystem.

If you want a longer list of the features to look forward to in this release, check out Stephanie Saad Cuthbertson’s blog on developer features as well as Dave Burke’s article on user features for the release.

Jetpack DataStore

There are two different APIs/approaches in DataStore. Preferences DataStore, which essentially takes the place of SharedPreferences completely, uses key-value pairs to store simple data, just like SharedPreferences. But Preferences DataStore is more powerful and robust than SharedPreferences, since it automatically handles proper asynchronous reads and writes (instead of SharedPreferences’ approach of synchronous writes… which you then have to figure out how to get off of the UI thread to accomplish).

The second API is Proto DataStore, which allows you to create a schema for richer, type-safe object data storage, backed by protobufs.

Start by checking out the DataStore article below. Then try out the Preferences codelab and Proto codelab to jump-start your learning, and download the library.

Articles & Videos

Adapting to Recent Android Privacy Changes

In particular, the article talks about:

  • Package access: Android 11 limits the visibility of packages on the device. That is, apps can no longer access information about other arbitrary apps on a user’s device. The article discusses the way this now works and also links to an implementation guide.
  • Incremental location permissions: Android 11 requires location access in foreground+background to be requested incrementally (first foreground, then background, which sends the user to Settings to grant the background location permission).
  • Foreground services for location, microphone, and camera access.
  • Non-resettable IDs: This change has evolved over several releases as we weaned developers off of non-resettable device identifiers. In Android 11, calls to getIccId() no longer return useful information, so you should find other means to get the information you need (hint: use resettable identifiers instead). For starters, read the guide we offer on Best practices for unique identifiers.

Android GPU inspector

Fast forward to… now, and Android GPU Inspector is available in “open beta” form, for everyone to use. (Read: It’s still beta, and the team is still working on it, but we’re now ready for more people to bang on it, try it out, and send us feedback.)

This tool is similar to other profiling tools we offer like Android Studio’s CPU profiler and the standalone systrace/perfetto tools, but it contains low-level info specific to GPUs that can help developers (especially those writing games and other performance-sensitive graphics apps) tune their 3D performance.

Android GPU Inspector depends on cooperation with device drivers, so device support is currently limited to Pixel 4 and Pixel 4 XL, but look for AGI to support more devices in the future.

You can download the tool here and learn more with the article and video below.

Podcast Episodes

ADB 148: [Constraint|Motion][Layout|Editor]

Sean McQuillan and I talked with Nicolas Roard and John Hoford about MotionEditor, which went stable recently in Android Studio 4.0. But as long as we were talking about that tool, we also talked extensively about MotionLayout in general as well as ConstraintLayout and other design tools.

Talking with Apples

Now then…

Android Developers

The official Android Developers publication on Medium