Android 11 introduces
great new features and APIs for developers.
New Experiences-
Device controls
Android 11 includes a new ControlsProviderService API that you can use to expose controls for connected, external devices. These controls appear under Device controls in the Android power menu.
Media
Controls
Android 11 updates how media controls are displayed. Media controls
appear near quick settings. Sessions from multiple apps are arranged in a
swipeable carousel which includes streams playing locally on the phone, remote
streams, such as those detected on external devices or cast sessions, and
previous, resumable sessions in the order they were last played.
Users can
restart previous sessions from the carousel without having to start the app.
When playback begins, the user interacts with the media controls in the usual
way.
Screens
Better support for
waterfall displays
Android 11
provides several APIs to support waterfall
displays, displays which wrap around the edge of the device. These
displays are treated as a variant of displays with display cutouts. The
existing DisplayCutout
.getSafeInset()
methods now
return the safe inset to avoid waterfall areas as well as cutouts. To render
your app content in the waterfall area, do the following:
·
Call DisplayCutout.getWaterfallInsets()
to get exact dimensions of the waterfall inset.
·
Set the window layout attribute layoutInDisplayCutoutMode
to LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
to allow the window to extend into the cutout and waterfall areas on all edges
of the screen. You must make sure that no essential content is in the cutout or
waterfall areas.
Hinge Angle Sensor and Foldables
Android 11
makes it possible for apps running on devices with hinge-based screen
configurations to determine the angle of the hinge by providing a new sensor
with TYPE_HINGE_ANGLE
,
and a new SensorEvent
that
can monitor the hinge angle and provides a measurement in degrees between two
integral parts of the device. You can use these raw measurements to perform
granular animations as the user manipulates the device.
Conversations
Conversation improvements
Android 11
makes several improvements to the way conversations
are handled. Conversations are real-time, bidirectional communications
between two or more people. These conversations are given special prominence,
and users have several new options in how to interact with them.
Chat Bubbles
Bubbles are now available to developers to help surface
conversations across the system. Bubbles was an experimental feature in Android
10 that was enabled through a developer option; in Android 11, this is no
longer necessary.
If an app
targets Android 11 (API level 30) or higher, its notifications are
not presented as bubbles unless they fulfill the new conversation requirements. Specifically, the notification must
be associated with a shortcut.
Prior to
Android 11, if you wanted a notification to be bubbled, you needed to
explicitly specify that the notification was set to always launch in document
UI mode. Beginning with Android 11, you no longer need to explicitly make
that setting; if the notification is bubbled, the platform automatically sets
the notification to always launch in document UI mode.
There are several
improvements to bubble performance, and users have more flexibility in enabling
and disabling bubbles from each app. For developers who implemented
experimental support, there are a few changes to the APIs in Android 11:
- The
BubbleMetadata.Builder()
constructor with no parameters is deprecated. Instead, use either of the two new constructorsBubbleMetadata.Builder(PendingIntent, Icon)
orBubbleMetadata.Builder(String)
. - Create
BubbleMetadata
from a shortcut ID by callingBubbleMetadata.Builder(String)
. The string passed should match the shortcut ID provided toNotification.Builder
. - Create
bubble icons with
Icon.createWithContentUri()
, or with the new methodcreateWithAdaptiveBitmapContentUri()
.
5G visual
indicators
For
information on displaying 5G indicators on users' devices, see Tell your users when they're on 5G.
Privacy
Android 11
introduces many changes and restrictions to enhance user privacy. To learn
more,
Security
Biometric
authentication updates
To help you
control the level of security for your app's data, Android 11 provides
several improvements to biometric authentication. These changes also appear in
the Jetpack Biometric library.
Additional support for
auth-per-use keys
Android 11
provides more support for authentication
using auth-per-use keys.
Secure
sharing of large datasets
In some
situations, such as those that involve machine learning or media playback, your
app might want to use the same large dataset as another app. In previous
versions of Android, your app and another app would each need to download a
separate copy of the same dataset.
To help reduce data redundancy, both over the network and on disk, Android 11 allows these large datasets to be cached on the device using shared data blobs. To learn more about sharing datasets, see the in-depth guide on sharing large datasets.