弃用

随着每个版本的发布,特定的 Android API 可能会过时或需要重构,以提供更好的开发者体验或支持新的平台功能。在这些情况下,我们正式废弃了过时的 API,并引导开发者改用替代 API。

废弃意味着我们已结束对这些 API 的正式支持,但开发者仍可继续使用它们。本页重点介绍了此 Android 版本中一些值得注意的废弃情况。如需了解其他弃用情况,请参阅 API 差异报告

使用 Spatializer 取代 Virtualizer

Spatializer 类在 Android 12(API 级别 32)中首次添加,可让应用查询设备上声音空间化的功能和行为。在 Android 15 中,我们废弃了 Virtualizer 类。如果支持空间化,请改用 AudioAttributes.Builder.setSpatializationBehavior 来描述您希望的内容播放方式。

AndroidX media3 ExoPlayer 1.0 默认为多声道音频启用空间音频(如果设备支持)。如需了解更多信息,请参阅这篇近期博文空间音频文档,了解用于控制该功能的 API。

Android WebView 中已废弃 WebSQL

The setDatabaseEnabled and getDatabaseEnabled methods from WebSettings are now deprecated. These settings activated support for WebSQL inside Webview. WebSQL is now removed in Chrome and is now deprecated on Android Webview. These methods will become a no-op on all Android versions in the next 12 months.

The World Wide Web Consortium (W3C) encourages apps needing web databases to adopt Web Storage API technologies like localStorage and sessionStorage, or IndexedDB. SQLite Wasm in the browser backed by the Origin Private File System outlines a replacement set of technologies based on the SQLite database, compiled to Web Assembly (Wasm), and backed by the origin private file system to enable more direct migration of WebSQL code.