With each release, specific Android APIs may become obsolete or need to be refactored to provide a better developer experience or support new platform capabilities. In these cases, Android will officially deprecate the obsolete APIs and direct developers to new APIs to use instead.
Deprecation means that we’ve ended official support for the APIs, but they will continue to remain available to developers. This page highlights some of the deprecations in this release of Android. To see other deprecations, refer to the API diff report.
Starting with Android 12, the RenderScript APIs are deprecated. They will continue to function, but we expect that device and component manufacturers will stop providing hardware acceleration support over time. To take full advantage of GPU acceleration, we recommend migrating away from RenderScript.
Android playlists are deprecated. The API is no longer maintained but the current functionality remains for compatibility.
We recommend reading and saving playlists as m3u files.
Display API deprecations
Android devices are becoming available in many different form factors, such as
large screens, tablets, and foldables. In order to render content appropriately
for each device, your app needs to determine the screen or display size. Over
time Android provided different APIs for retrieving this information. In
Android 11 we introduced the
WindowMetrics API and deprecated
In Android 12 we continue to recommend using
and are deprecating these methods:
Apps should use the
WindowMetrics APIs to query the bounds of their window, or
to query the current density.
Here are some examples how to use
First, be sure your app can make its activities fully resizable.
An activity should rely upon
WindowMetrics from an activity context for
any UI-related work, particularly
If your app creates a
MediaProjection, the bounds must be correctly sized
since the projection captures the display. If the app is fully resizable, the
activity context returns the correct bounds.
WindowMetrics projectionMetrics = activityContext .getSystemService(WindowManager.class).getMaximumWindowMetrics();
If the app is not fully resizable, it must query the bounds from a
WindowContext instance, and retrieve the WindowMetrics of the maximum display
area available to the application using
Context windowContext = mContext.createWindowContext(mContext.getDisplay(), TYPE_APPLICATION, null /* options */); WindowMetrics projectionMetrics = windowContext.getWindowManager() .getMaximumWindowMetrics();