Android 11: Developer Preview 2

Dial it up to Android 11

I talked about the first preview for Android 11 in episode #13. And now, the next release has already dropped. Dave Burke posted an overview of the release on the Android Developers Blog. Check out the preview for updates to some of the features that were already in the release, as well as some new shiny features that are just now available, including my personal favorite feature: IME animation control.

Synchronized IME Animations

For a platform developer, all new features are like our children: we have no favorites. But really, IME animation control is my favorite-favorite feature. You’ve been asking us for this feature (and we’ve been wanting it ourselves!) for several years, and now it’s here.

The idea is that the IME (keyboard) pops up on its own when keyboard entry is needed. This is the functionality the user needs, but it doesn’t provide the experience that users or developers want, because the appearance creates a visual discontinuity by simply popping into place, causing the apps to snap into their adjusted layout given the change in available screen real estate. The keyboard actually does animate in… but the app snaps instantly to the post-animation size, causing this visual hiccup.

What developers want, and what the new APIs provide, is the ability to both listen to information about the IME position as it animates in (so that apps can synchronize their own animations to suit) and to control the animation of the IME. Between the listener and the animation control, applications now have enough capability to create experiences that blend the change in the application UI with the animation of the IME itself, providing a much better experience.

By the way, this feature has actually been in the works for a while. In fact, it nearly hit Android 10… but wasn’t quite ready, so we had to finish it up for Android 11 instead.

NDK Image Decoder

Another new API added in Android 11 is an image decoder for the NDK, especially for you native-code developers out there. If you’re currently jumping up through JNI to decode your images through the platform APIs or worse (from an app-size standpoint at least), bundling other libraries to handle image decoding, then we have a deal for you…

You can now use the new NDK ImageDecoder API to handle images in common formats (such as JPEG, PNG, GIF, WebP, and HEIF). Check out the NDK guide for more information. Also check out the ImageDecoder sample, especially Texture.cpp, to see how it works.

Nullability in Android 11

We also added new nullability annotations to the SDK APIs in Android 11.

David Winer posted this article on the Android Developers Blog:

which talks about nullability in Kotlin and how that works with APIs written in the Java programming language (which supports nullability through annotations, as opposed to Kotlin’s language support for nullability).

Specifically, Android 11 introduced new annotations across the API that may introduce new warnings and errors when building (it’s a good thing! Catch those problems at build time instead of at runtime!). Some APIs that used to have @RecentlyNullable or @RecentlyNonNull (which may throw warnings from the Kotlin compiler when used incorrectly) were upgraded to @Nullable and @NonNull (which generate build-time errors instead). We also added new @RecentlyNullable and @RecentlyNonNull annotations to APIs that did not yet have any annotations. So build your apps and look for new warnings and errors to fix.

But Wait, There’s More!

Other things we’ve added to Android 11 since the last preview release include:

There is now a hinge angle sensor for foldable devices.

NNAPI added a “hard-swish op,” which enables faster and more accurate training. I’m not sure of the details here, but I like the name. Bonus points for the very academic article that explains the theory behind swish activation functions if you want to know more.

Starting in Android 11, apps that want to use the microphone or camera from a foreground service need to add the foregroundServiceType attribute to their manifest, just like the location changes in Android 10. Note that we also talked about this change with the engineering team in episode 133 of the ADB podcast, Power Play.

Apps can now request variable refresh rates on supporting devices.

The emulator now supports both front and back cameras.

The whole reason that we do preview releases is to give you a chance to try your app out on these early releases to make sure that things are working for you. This extra time gives you a chance to either fix problems if you see any, or to report issues for us to fix before we finish up the release and ship the final version. To help you, we’ve added a new settings screen in developer options where you can toggle various behavior changes to see whether they have any impact on your situation. So now would be an excellent time to try out Android 11 and see how it’s working for you.

Read Dave Burke’s post for more information, or go get all of the details and the bits on the Android 11 Preview site. And please give us feedback if you have any, or even fill out a survey to let us know your thoughts on the updates and changes.