Android 12 introduces great new features and APIs for developers. The sections below help you learn about features for your apps and get started with the related APIs.
For a detailed list of new, modified, and removed APIs, read the API diff report. For details on new APIs visit the Android API reference — new APIs are highlighted for visibility. Also, to learn about areas where platform changes may affect your apps, be sure to check out Android 12 behavior changes for apps that target Android 12 and for all apps.
New experiences
Unified API for receiving content
Android 12 introduces a new unified API that lets you receive rich content from any available source: clipboard, keyboard, or drag and drop.
For more information, see Unified API for receiving content.
Media
Compatible media transcoding
Android 12 can automatically transcode HEVC(H.265) and HDR (HDR10 and HDR10+) videos recorded on the device to AVC (H.264), a format which is widely compatible with standard players. This takes advantage of modern codecs when they are available without sacrificing compatibility with older applications.
See compatible media transcoding for more details.
AVIF image support
Android 12 introduces support for images that use the AV1 Image File Format (AVIF). AVIF is a container format for images and sequences of images encoded using AV1. It takes advantage of the intra-frame encoded content from video compression. This dramatically improves image quality for the same file size when compared to older image formats, such as JPEG. For an in depth look at the advantages of this format, see Jake Archibald's blog post.
Generate haptic effects from audio
Android 12 apps can generate haptic feedback derived from an audio session using the phone's vibrator. This provides an opportunity for more immersive game and audio experiences. For example, haptic-enhanced ringtones can help identify callers, or a driving game could simulate the feeling of rough terrain.
See the HapticGenerator reference documentation for more information.
Native ImageDecoder support for animated GIF and WebP
In Android 12, the NDK
ImageDecoder
API has been expanded
to decode all frames and timing data from images
that use the animated GIF and
animated WebP file formats. When it
was introduced in Android 11, this API decoded only the first image from
animations in these formats.
Use ImageDecoder
instead of third-party libraries to further decrease APK
size
and benefit from future updates related to security and performance.
For more details on the API, refer to the API reference and the sample on GitHub.
Security
Device properties verification available in non-DPC apps
Android 12 expands the set of apps that can verify the device properties that are in an attestation certificate when these apps generate a new key.
As of Android 9 (API level 28), device policy
owners (DPOs) that use
Keymaster 4.0 or higher can
verify the device properties in these attestation certificates. Starting in
Android 12, any app that targets Android 12 can perform this verification using
the
setDevicePropertiesAttestationIncluded()
method.
The generated device properties include the following
Build
fields:
BRAND
DEVICE
MANUFACTURER
MODEL
PRODUCT
Connectivity
Wi-Fi Aware (NAN) enhancements
Android 12 adds some enhancements to Wi-Fi Aware:
- On devices running Android 12 and higher, you can use the
onServiceLost()
callback to be alerted when your app has lost a discovered service due to the service stopping or moving out of range. - The way that multiple data-paths (NAN Data Paths) are set up is changing to be more efficient. Earlier versions used L2 messaging to exchange peer information of the initiators, which introduced latency. On devices running Android 12 and higher, the responder (server) can be configured to accept any peer—that is, it doesn’t need to know the initiator information upfront. This speeds up datapath bringup and enables multiple point-to-point links with only one network request.
- To prevent the framework from rejecting discovery or connection requests due
to running out of resources, on devices running Android 12 and
higher, you can call
WifiAwareManager.getAvailableAwareResources()
. This method's return value lets you get the number of available data paths, the number of available publish sessions, and the number of available subscribe sessions.