功能與 API 總覽

Android 15 為開發人員推出了強大的新功能和 API。以下各節會概述這些功能,協助您開始使用相關 API。

如需新增、修改及移除 API 的詳細清單,請參閱 API 差異比較表。如要進一步瞭解新增的 API,請參閱 Android API 參考資料。如果是 Android 15,請找出在 API 級別 35 中新增的 API。如要瞭解平台變更可能對應用程式造成的影響,請務必查看指定 Android 15 的應用程式所有應用程式 的 Android 15 行為變更。

相機和媒體

Android 15 包含多種功能,可改善相機和媒體體驗,並提供工具和硬體,協助創作者在 Android 上實現創作構想。

如要進一步瞭解 Android 媒體和相機的最新功能和開發人員解決方案,請參閱 Google I/O 大會的「建構現代化 Android 媒體和相機體驗」演講。

低光源增強

Android 15 introduces Low Light Boost, an auto-exposure mode available to both Camera 2 and the night mode camera extension. Low Light Boost adjusts the exposure of the Preview stream in low-light conditions. This is different from how the night mode camera extension creates still images, because night mode combines a burst of photos to create a single, enhanced image. While night mode works very well for creating a still image, it can't create a continuous stream of frames, but Low Light Boost can. Thus, Low Light Boost enables camera capabilities, such as:

  • Providing an enhanced image preview, so users are better able to frame their low-light pictures
  • Scanning QR codes in low light

If you enable Low Light Boost, it automatically turns on when there's a low light level, and turns off when there's more light.

Apps can record off the Preview stream in low-light conditions to save a brightened video.

For more information, see Low Light Boost.

應用程式內攝影機控制項

Android 15 新增了擴充功能,讓你在支援的裝置上進一步控管相機硬體及其演算法:

  • 進階閃光燈強度調整功能,可讓您在拍照時精確控制 SINGLETORCH 模式的閃光燈強度。

HDR 頭尾空間控制

Android 15 会选择适合底层设备功能和面板的位深的 HDR 余量。对于包含大量 SDR 内容的页面(例如显示单个 HDR 缩略图的即时通讯应用),此行为最终可能会对 SDR 内容的感知亮度产生不利影响。Android 15 允许您使用 setDesiredHdrHeadroom 控制 HDR 余量,以在 SDR 和 HDR 内容之间取得平衡。

左侧屏幕上 SDR 界面元素的亮度似乎比右侧屏幕的亮度更均匀,这模拟了混合 HDR 和 SDR 内容时可能出现的余量问题。通过调整 HDR 余量,您可以在 SDR 和 HDR 内容之间更好地平衡。

音量控制

Android 15 introduces support for the CTA-2075 loudness standard to help you avoid audio loudness inconsistencies and ensure users don't have to constantly adjust volume when switching between content. The system leverages known characteristics of the output devices (headphones and speaker) along with loudness metadata available in AAC audio content to intelligently adjust the audio loudness and dynamic range compression levels.

To enable this feature, you need to ensure loudness metadata is available in your AAC content and enable the platform feature in your app. For this, you instantiate a LoudnessCodecController object by calling its create factory method with the audio session ID from the associated AudioTrack; this automatically starts applying audio updates. You can pass an OnLoudnessCodecUpdateListener to modify or filter loudness parameters before they are applied on the MediaCodec.

// Media contains metadata of type MPEG_4 OR MPEG_D
val mediaCodec = 
val audioTrack = AudioTrack.Builder()
                                .setSessionId(sessionId)
                                .build()
...
// Create new loudness controller that applies the parameters to the MediaCodec
try {
   val lcController = LoudnessCodecController.create(mSessionId)
   // Starts applying audio updates for each added MediaCodec
}

AndroidX media3 ExoPlayer will also be updated to use the LoudnessCodecController APIs for a seamless app integration.

虛擬 MIDI 2.0 裝置

Android 13 添加了对使用 USB 连接 MIDI 2.0 设备的支持,这些设备使用通用 MIDI 数据包 (UMP) 进行通信。Android 15 将 UMP 支持扩展到虚拟 MIDI 应用,使乐曲应用能够控制合成器应用 作为虚拟 MIDI 2.0 设备,就像使用 USB MIDI 2.0 设备一样。

更有效率的 AV1 軟體解碼

dav1d 標誌

dav1d 是 VideoLAN 的熱門 AV1 軟體解碼器,現可用於硬體中不支援 AV1 解碼的 Android 裝置。dav1d 的效能比舊版 AV1 軟體解碼器高出 3 倍,可讓更多使用者 (包括一些低階和中階裝置) 透過 HD AV1 播放。

目前,應用程式必須以 "c2.android.av1-dav1d.decoder" 的名稱叫用 dav1d,以便選擇加入 dav1d。後續更新會將 dav1d 設為預設 AV1 軟體解碼器。這項支援功能經過標準化及向後移植至收到 Google Play 系統更新的 Android 11 裝置。

開發人員工作效率和工具

雖然我們大部分的工作都是圍繞著 Android StudioJetpack ComposeAndroid Jetpack 程式庫等工具,來提升您的工作效率,但我們也一直在尋找各種方法,讓您能更輕鬆地在平台上實現願景。

OpenJDK 17 更新

Android 15 continues the work of refreshing Android's core libraries to align with the features in the latest OpenJDK LTS releases.

The following key features and improvements are included:

These APIs are updated on over a billion devices running Android 12 (API level 31) and higher through Google Play System updates, so you can target the latest programming features.

PDF 改善功能

Android 15 includes substantial improvements to the PdfRenderer APIs. Apps can incorporate advanced features such as rendering password-protected files, annotations, form editing, searching, and selection with copy. Linearized PDF optimizations are supported to speed local PDF viewing and reduce resource use. The Jetpack PDF library uses these APIs to simplify adding PDF viewing capabilities to your app.

The latest updates to PDF rendering include features such as searching an embedded PDF file.

The PdfRenderer has been moved to a module that can be updated using Google Play system updates independent of the platform release, and we're supporting these changes back to Android 11 (API level 30) by creating a compatible pre-Android 15 version of the API surface, called PdfRendererPreV.

自動切換語言的細微調整

Android 14 增加了设备端音频中的多语言识别功能,可在语言之间自动切换,但这可能会导致单词丢失,尤其是在语言切换时,两种话语之间的停顿较少时。Android 15 添加了额外的控件,可帮助应用根据其用例调整此切换。EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS 会将自动切换限制为仅在音频会话开始时进行,而 EXTRA_LANGUAGE_SWITCH_MATCH_SWITCHES 则会在指定次数的切换后停用语言切换。如果您希望自动检测到会话期间只讲一种语言,这些选项特别有用。

改善 OpenType Variable Font API

Android 15 improves the usability of the OpenType variable font. You can create a FontFamily instance from a variable font without specifying weight axes with the buildVariableFamily API. The text renderer overrides the value of wght axis to match the displaying text.

Using the API simplifies the code for creating a Typeface considerably:

Kotlin

val newTypeface = Typeface.CustomFallbackBuilder(
            FontFamily.Builder(
                Font.Builder(assets, "RobotoFlex.ttf").build())
                    .buildVariableFamily())
    .build()

Java

Typeface newTypeface = Typeface.CustomFallbackBuilder(
            new FontFamily.Builder(
                new Font.Builder(assets, "RobotoFlex.ttf").build())
                    .buildVariableFamily())
    .build();

Previously, to create the same Typeface, you would need much more code:

Kotlin

val oldTypeface = Typeface.CustomFallbackBuilder(
            FontFamily.Builder(
                Font.Builder(assets, "RobotoFlex.ttf")
                    .setFontVariationSettings("'wght' 400")
                    .setWeight(400)
                    .build())
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 100")
                        .setWeight(100)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 200")
                        .setWeight(200)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 300")
                        .setWeight(300)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 500")
                        .setWeight(500)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 600")
                        .setWeight(600)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 700")
                        .setWeight(700)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 800")
                        .setWeight(800)
                        .build()
                )
                .addFont(
                    Font.Builder(assets, "RobotoFlex.ttf")
                        .setFontVariationSettings("'wght' 900")
                        .setWeight(900)
                        .build()
                ).build()
        ).build()

Java

Typeface oldTypeface = new Typeface.CustomFallbackBuilder(
    new FontFamily.Builder(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 400")
            .setWeight(400)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 100")
            .setWeight(100)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 200")
            .setWeight(200)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 300")
            .setWeight(300)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 500")
            .setWeight(500)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 600")
            .setWeight(600)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 700")
            .setWeight(700)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 800")
            .setWeight(800)
            .build()
    )
    .addFont(
        new Font.Builder(assets, "RobotoFlex.ttf")
            .setFontVariationSettings("'wght' 900")
            .setWeight(900)
            .build()
    )
    .build()
).build();

Here's an example of how a Typeface created with both the old and new APIs renders:

An example of how Typeface rendering differs using new and old
APIs

In this example, the Typeface created with the old API doesn't have the capability to create accurate font weights for the 350, 450, 550 and 650 Font instances, so the renderer falls back to the closest weight. So in this case, 300 is rendered instead of 350, 400 is rendered instead of 450, and so on. By contrast, the Typeface created with the new APIs dynamically creates a Font instance for a given weight, so accurate weights are rendered for 350, 450, 550, and 650 as well.

精細的換行控制

Starting in Android 15, a TextView and the underlying line breaker can preserve the given portion of text in the same line to improve readability. You can take advantage of this line break customization by using the <nobreak> tag in string resources or createNoBreakSpan. Similarly, you can preserve words from hyphenation by using the <nohyphen> tag or createNoHyphenationSpan.

For example, the following string resource doesn't include a line break, and renders with the text "Pixel 8 Pro." breaking in an undesirable place:

<resources>
    <string name="pixel8pro">The power and brains behind Pixel 8 Pro.</string>
</resources>

In contrast, this string resource includes the <nobreak> tag, which wraps the phrase "Pixel 8 Pro." and prevents line breaks:

<resources>
    <string name="pixel8pro">The power and brains behind <nobreak>Pixel 8 Pro.</nobreak></string>
</resources>

The difference in how these strings are rendered is shown in the following images:

Layout for a line of text where the phrase "Pixel 8 Pro." isn't wrapped using a <nobreak> tag.
Layout for the same line of text where the phrase "Pixel 8 Pro." is wrapped using a <nobreak> tag.

應用程式封存

Android 和 Google Play 宣布支持最后的应用归档功能 年,这让用户可以通过移除部分内容来释放空间 通过 Android 应用发布的设备中不常用的应用 前往 Google Play 下载套装。Android 15 在操作系统级别支持应用归档和解压缩,让所有应用商店都能更轻松地实现归档和解压缩。

具有 REQUEST_DELETE_PACKAGES 权限的应用可以调用 PackageInstaller requestArchive 方法请求归档 已安装的应用软件包,这会移除 APK 和所有缓存的文件,但会保留 用户数据已归档的应用会通过 LauncherApps API 作为可显示的应用返回;用户会看到一个界面处理,以突出显示这些应用已归档。如果用户点按已归档的应用,负责安装的应用会收到解除归档请求,并且可以通过 ACTION_PACKAGE_ADDED 广播监控恢复过程。

圖形

Android 15 提供最新的圖形改善功能,包括 ANGLE 和 Canvas 圖形系統的新增功能。

改良 Android 的 GPU 存取權

Vulkan logo

Android hardware has evolved quite a bit from the early days where the core OS would run on a single CPU and GPUs were accessed using APIs based on fixed-function pipelines. The Vulkan® graphics API has been available in the NDK since Android 7.0 (API level 24) with a lower-level abstraction that better reflects modern GPU hardware, scales better to support multiple CPU cores, and offers reduced CPU driver overhead — leading to improved app performance. Vulkan is supported by all modern game engines.

Vulkan is Android's preferred interface to the GPU. Therefore, Android 15 includes ANGLE as an optional layer for running OpenGL® ES on top of Vulkan. Moving to ANGLE will standardize the Android OpenGL implementation for improved compatibility, and, in some cases, improved performance. You can test out your OpenGL ES app stability and performance with ANGLE by enabling the developer option in Settings -> System -> Developer Options -> Experimental: Enable ANGLE on Android 15.

The Android ANGLE on Vulkan roadmap

Roadmap of upcoming changes to the Android GPU APIs.

As part of streamlining our GPU stack, going forward we will be shipping ANGLE as the GL system driver on more new devices, with the future expectation that OpenGL/ES will be only available through ANGLE. That being said, we plan to continue support for OpenGL ES on all devices.

Recommended next steps

Use the developer options to select the ANGLE driver for OpenGL ES and test your app. For new projects, we strongly encourage using Vulkan for C/C++.

改善 Canvas

Android 15 继续对 Android 的 Canvas 图形系统进行现代化改造,并增添了新功能:

  • Matrix44 提供了一个用于转换坐标的 4x4 矩阵,当您想要处理 3D 画布时,应使用此矩阵。
  • clipShader 将当前裁剪与指定着色器相交,而 clipOutShader 会将裁剪设置为当前裁剪和着色器的差异,其中各自将着色器视为 Alpha 蒙版。这有助于高效绘制复杂形状。

效能和電池

Android 持續專注於協助您改善應用程式的效能和品質。Android 15 推出了可協助您提高應用程式執行效率、改善應用程式效能,以及收集應用程式相關深入分析資訊的 API。

如要瞭解省電最佳做法、網路和電力使用情況偵錯,以及我們如何改善 Android 15 和近期 Android 版本的背景工作電池效率,請參閱 Google I/O 的「Improving battery efficiency of background work on Android」(改善 Android 背景工作電池效率) 演講。

ApplicationStartInfo API

In previous versions of Android, app startup has been a bit of a mystery. It was challenging to determine within your app whether it started from a cold, warm, or hot state. It was also difficult to know how long your app spent during the various launch phases: forking the process, calling onCreate, drawing the first frame, and more. When your Application class was instantiated, you had no way of knowing whether the app started from a broadcast, a content provider, a job, a backup, boot complete, an alarm, or an Activity.

The ApplicationStartInfo API on Android 15 provides all of this and more. You can even choose to add your own timestamps into the flow to help collect timing data in one place. In addition to collecting metrics, you can use ApplicationStartInfo to help directly optimize app startup; for example, you can eliminate the costly instantiation of UI-related libraries within your Application class when your app is starting up due to a broadcast.

詳細的應用程式大小資訊

自 Android 8.0(API 级别 26)起,Android 就一直包含 StorageStats.getAppBytes API,该 API 将应用的安装大小汇总为一个字节,这些字节是 APK 大小、从 APK 中提取的文件的大小以及设备上生成的文件(例如预先 (AOT) 编译代码)的总和。就应用的存储空间使用情况而言,此数字并不富有见解。

Android 15 增加了 StorageStats.getAppBytesByDataType([type]) API,可让您深入了解应用如何使用所有空间,包括 APK 文件拆分、AOT 和加速相关代码、dex 元数据、库和引导式配置文件。

應用程式管理的剖析

Android 15 包含 ProfilingManager 类,可让您从应用内部收集性能分析信息,例如堆转储、堆分析报告、堆栈采样等。它使用提供的标记为您的应用提供回调,以标识输出文件,该文件将传递给应用的文件目录。该 API 会进行速率限制,以尽可能降低对性能的影响。

为了简化在应用中构建性能分析请求的过程,我们建议您使用 Core 1.15.0-rc01 或更高版本中的相应 Profiling AndroidX API。

SQLite 資料庫改善項目

Android 15 introduces SQLite APIs that expose advanced features from the underlying SQLite engine that target specific performance issues that can manifest in apps. These APIs are included with the update of SQLite to version 3.44.3.

Developers should consult best practices for SQLite performance to get the most out of their SQLite database, especially when working with large databases or when running latency-sensitive queries.

  • Read-only deferred transactions: when issuing transactions that are read-only (don't include write statements), use beginTransactionReadOnly() and beginTransactionWithListenerReadOnly(SQLiteTransactionListener) to issue read-only DEFERRED transactions. Such transactions can run concurrently with each other, and if the database is in WAL mode, they can run concurrently with IMMEDIATE or EXCLUSIVE transactions.
  • Row counts and IDs: APIs were added to retrieve the count of changed rows or the last inserted row ID without issuing an additional query. getLastChangedRowCount() returns the number of rows that were inserted, updated, or deleted by the most recent SQL statement within the current transaction, while getTotalChangedRowCount() returns the count on the current connection. getLastInsertRowId() returns the rowid of the last row to be inserted on the current connection.
  • Raw statements: issue a raw SQlite statement, bypassing convenience wrappers and any additional processing overhead that they may incur.

Android 動態效能架構更新

Android 15 continues our investment in the Android Dynamic Performance Framework (ADPF), a set of APIs that allow games and performance intensive apps to interact more directly with power and thermal systems of Android devices. On supported devices, Android 15 adds ADPF capabilities:

  • A power-efficiency mode for hint sessions to indicate that their associated threads should prefer power saving over performance, great for long-running background workloads.
  • GPU and CPU work durations can both be reported in hint sessions, allowing the system to adjust CPU and GPU frequencies together to best meet workload demands.
  • Thermal headroom thresholds to interpret possible thermal throttling status based on headroom prediction.

To learn more about how to use ADPF in your apps and games, head over to the documentation.

隱私權

Android 15 包含多種功能,可協助應用程式開發人員保護使用者隱私。

螢幕錄影偵測

Android 15 新增支援應用程式,偵測出 。每當應用程式在螢幕錄影中從可見轉為不可見,系統就會叫用回呼。如果系統正在記錄註冊程序的 UID 所擁有的活動,就會將應用程式視為可見。這樣一來,如果應用程式執行敏感作業,您就可以通知使用者正在進行錄影。

val mCallback = Consumer<Int> { state ->
  if (state == SCREEN_RECORDING_STATE_VISIBLE) {
    // We're being recorded
  } else {
    // We're not being recorded
  }
}

override fun onStart() {
   super.onStart()
   val initialState =
      windowManager.addScreenRecordingCallback(mainExecutor, mCallback)
   mCallback.accept(initialState)
}

override fun onStop() {
    super.onStop()
    windowManager.removeScreenRecordingCallback(mCallback)
}

擴充的 IntentFilter 功能

Android 15 通过 UriRelativeFilterGroup 支持更精确的 Intent 解析,UriRelativeFilterGroup 包含一组 UriRelativeFilter 对象,这些对象构成一组必须满足的 Intent 匹配规则,包括网址查询参数、网址片段以及屏蔽或排除规则。

您可以在 AndroidManifest XML 文件中使用 <uri-relative-filter-group> 标记来定义这些规则,该标记可以包含 android:allow 标记。这些代码可以包含使用现有数据代码属性以及 android:queryandroid:fragment 属性的 <data> 代码。

下面是一个 AndroidManifest 语法示例:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.BROWSABLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="http" />
  <data android:scheme="https" />
  <data android:domain="astore.com" />
  <uri-relative-filter-group>
    <data android:pathPrefix="/auth" />
    <data android:query="region=na" />
  </uri-relative-filter-group>
  <uri-relative-filter-group android:allow="false">
    <data android:pathPrefix="/auth" />
    <data android:query="mobileoptout=true" />
  </uri-relative-filter-group>
  <uri-relative-filter-group android:allow="false">
    <data android:pathPrefix="/auth" />
    <data android:fragmentPrefix="faq" />
  </uri-relative-filter-group>
</intent-filter>

私人空間

The private space can be unlocked and locked to show or hide sensitive apps on a device.

Private space lets users create a separate space on their device where they can keep sensitive apps away from prying eyes, under an additional layer of authentication. The private space uses a separate user profile. The user can choose to use the device lock or a separate lock factor for the private space.

Apps in the private space show up in a separate container in the launcher, and are hidden from the recents view, notifications, settings, and from other apps when the private space is locked. User-generated and downloaded content (such as media or files) and accounts are separated between the private space and the main space. The system sharesheet and the photo picker can be used to give apps access to content across spaces when the private space is unlocked.

Users can't move existing apps and their data into the private space. Instead, users select an install option in the private space to install an app using whichever app store they prefer. Apps in the private space are installed as separate copies from any apps in the main space (new copies of the same app).

When a user locks the private space, the profile is stopped. While the profile is stopped, apps in the private space are no longer active and can't perform foreground or background activities, including showing notifications.

We recommend that you test your app with private space to make sure your app works as expected, especially if your app falls into one of the following categories:

查詢使用者最近一次選取的「指定相片存取權」

應用程式現在只會在授予部分存取權媒體權限時,突顯最近選取的相片和影片。這項功能可改善經常要求存取相片和影片存取權的應用程式使用者體驗。如要在應用程式中使用這項功能,請透過 ContentResolver 查詢 MediaStore 時啟用 QUERY_ARG_LATEST_SELECTION_ONLY 引數。

Kotlin

val externalContentUri = MediaStore.Files.getContentUri("external")

val mediaColumns = arrayOf(
   FileColumns._ID,
   FileColumns.DISPLAY_NAME,
   FileColumns.MIME_TYPE,
)

val queryArgs = bundleOf(
   // Return only items from the last selection (selected photos access)
   QUERY_ARG_LATEST_SELECTION_ONLY to true,
   // Sort returned items chronologically based on when they were added to the device's storage
   QUERY_ARG_SQL_SORT_ORDER to "${FileColumns.DATE_ADDED} DESC",
   QUERY_ARG_SQL_SELECTION to "${FileColumns.MEDIA_TYPE} = ? OR ${FileColumns.MEDIA_TYPE} = ?",
   QUERY_ARG_SQL_SELECTION_ARGS to arrayOf(
       FileColumns.MEDIA_TYPE_IMAGE.toString(),
       FileColumns.MEDIA_TYPE_VIDEO.toString()
   )
)

Java

Uri externalContentUri = MediaStore.Files.getContentUri("external");

String[] mediaColumns = {
    FileColumns._ID,
    FileColumns.DISPLAY_NAME,
    FileColumns.MIME_TYPE
};

Bundle queryArgs = new Bundle();
queryArgs.putBoolean(MediaStore.QUERY_ARG_LATEST_SELECTION_ONLY, true);
queryArgs.putString(MediaStore.QUERY_ARG_SQL_SORT_ORDER, FileColumns.DATE_ADDED + " DESC");
queryArgs.putString(MediaStore.QUERY_ARG_SQL_SELECTION, FileColumns.MEDIA_TYPE + " = ? OR " + FileColumns.MEDIA_TYPE + " = ?");
queryArgs.putStringArray(MediaStore.QUERY_ARG_SQL_SELECTION_ARGS, new String[] {
    String.valueOf(FileColumns.MEDIA_TYPE_IMAGE),
    String.valueOf(FileColumns.MEDIA_TYPE_VIDEO)
});

Android 版 Privacy Sandbox

Android 15 包含最新的 Android 广告服务扩展程序,以及最新版 Privacy Sandbox on Android。我们致力于开发新的技术,以便更好地保护用户隐私,并为移动应用打造有效的个性化广告体验。这项新功能是我们的工作的一部分。我们的隐私沙盒页面详细介绍了 Privacy Sandbox on Android 开发者预览版和 Beta 版计划,以帮助您开始使用。

Health Connect

Android 15 integrates the latest extensions around Health Connect by Android, a secure and centralized platform to manage and share app-collected health and fitness data. This update adds support for additional data types across fitness, nutrition, skin temperature, training plans, and more.

Skin temperature tracking allows users to store and share more accurate temperature data from a wearable or other tracking device.

Training plans are structured workout plans to help a user achieve their fitness goals. Training plans support includes a variety of completion and performance goals:

Learn more about the latest updates to Health Connect in Android in the Building adaptable experiences with Android Health talk from Google I/O.

分享應用程式畫面

Android 15 支援應用程式畫面分享功能,因此使用者可以只分享或錄製應用程式視窗,而非整個裝置畫面。這項功能最初是在 Android 14 QPR2 中啟用,其中包含 MediaProjection 回呼,可讓應用程式自訂應用程式螢幕分享體驗。請注意,如果應用程式指定 Android 14 (API 級別 34) 以上版本,則每個 MediaProjection 擷取工作階段都需要使用者同意

使用者體驗和系統使用者介面

Android 15 可讓應用程式開發人員和使用者更靈活地控管裝置設定,以符合自身需求。

如要進一步瞭解如何運用 Android 15 的最新改善項目來改善應用程式的使用者體驗,請參閱 Google I/O 大會的「改善 Android 應用程式的使用者體驗」演講。

使用 Generated Previews API 提供更豐富的小工具預覽畫面

在 Android 15 之前,提供微件选择器预览的唯一方法是指定静态图片或布局资源。这些预览通常与放置在主屏幕上的实际 widget 的外观大不相同。此外,由于无法使用 Jetpack Glance 创建静态资源,因此“资讯一览” 开发者必须为其微件截屏或创建 XML 布局, 微件预览。

Android 15 添加了对生成的预览的支持。这意味着,应用微件提供程序可以生成 RemoteViews 以用作选择器预览,而不是静态资源。

应用可以向微件选择器提供远程视图, 更新选择器中的内容,使其更能代表用户的内容 看到的内容。

推送 API

应用可以通过推送 API 提供生成的预览。应用可以提供 预览,并且不会收到明确的请求, 以提供预览。预览会保留在 AppWidgetService 中,并且主持人可以按需请求预览。以下示例加载了一个 XML 微件 并将其设置为预览:

AppWidgetManager.getInstance(appContext).setWidgetPreview(
   ComponentName(
       appContext,
       SociaLiteAppWidgetReceiver::class.java
   ),
   AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
   RemoteViews("com.example", R.layout.widget_preview)
)

预期的流程如下:

  1. 任何时候,widget 提供程序都会调用 setWidgetPreview。提供的预览会与其他提供方信息一起保留在 AppWidgetService 中。
  2. setWidgetPreview 会通过 AppWidgetHost.onProvidersChanged 回调。作为回应,微件宿主会重新加载其所有提供方信息。
  3. 显示微件预览时,主机会检查 AppWidgetProviderInfo.generatedPreviewCategories,如果所选类别可用,则调用 AppWidgetManager.getWidgetPreview 以返回此提供程序的已保存预览。

何时调用 setWidgetPreview

由于没有用于提供预览的回调,因此应用可以选择在运行期间的任何时间发送预览。预览的更新频率取决于微件的用例。

以下列表介绍了两大类预览用例:

  • 在 widget 预览中显示真实数据(例如个性化数据)的提供程序 或最新信息。这些提供商可以设置预览 已登录 Google 账号或已在其应用中完成初始配置。之后 可以设置一项定期任务,按照所选的节奏更新预览。 此类 widget 的示例包括照片、日历、天气或新闻 widget。
  • 在预览中显示静态信息或不显示任何数据的快捷操作 widget 的提供程序。这些提供程序可以在应用首次启动时设置预览一次。例如,快速开车便是此类微件的示例 操作 widget 或 Chrome 快捷方式 widget。

某些提供商可能会在基座接入模式选择器上显示静态预览,但真实的 信息。这些提供商应遵循指南 设置预览

子母畫面

Android 15 对画中画 (PiP) 模式进行了更改,确保在进入画中画模式时实现更流畅的转换。对于在主界面上叠加界面元素的应用,这将非常有用,因为这些元素会进入 PiP。

开发者使用 onPictureInPictureModeChanged 回调来定义用于切换叠加界面元素可见性的逻辑。当 PiP 进入或退出动画完成时,系统会触发此回调。从 Android 15 开始,PictureInPictureUiState 类包含另一种状态。

在这种界面状态下,以 Android 15(API 级别 35)为目标平台的应用会在画中画动画开始后立即观察到使用 isTransitioningToPip() 调用的 Activity#onPictureInPictureUiStateChanged 回调。在 PiP 模式下,许多界面元素与应用无关,例如包含建议、即将播放的视频、评分和标题等信息的视图或布局。当应用进入画中画模式时,请使用 onPictureInPictureUiStateChanged 回调隐藏这些界面元素。当应用从画中画窗口进入全屏模式时,请使用 onPictureInPictureModeChanged 回调取消隐藏这些元素,如以下示例所示:

override fun onPictureInPictureUiStateChanged(pipState: PictureInPictureUiState) {
        if (pipState.isTransitioningToPip()) {
          // Hide UI elements
        }
    }
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
        if (isInPictureInPictureMode) {
          // Unhide UI elements
        }
    }

不相关界面元素(适用于画中画窗口)的这种快速可见性切换有助于确保画中画进入动画更流畅、不闪烁。

改善「零打擾」規則

AutomaticZenRule lets apps customize Attention Management (Do Not Disturb) rules and decide when to activate or deactivate them. Android 15 greatly enhances these rules with the goal of improving the user experience. The following enhancements are included:

  • Adding types to AutomaticZenRule, allowing the system to apply special treatment to some rules.
  • Adding an icon to AutomaticZenRule, helping to make the modes be more recognizable.
  • Adding a triggerDescription string to AutomaticZenRule that describes the conditions on which the rule should become active for the user.
  • Added ZenDeviceEffects to AutomaticZenRule, allowing rules to trigger things like grayscale display, night mode, or dimming the wallpaper.

為通知管道設定 VibrationEffect

Android 15 支持为传入的通知设置丰富的振动,方法是 频道使用的是NotificationChannel.setVibrationEffect,因此 您的用户可以区分不同类型的通知 不需要看他们的设备

媒體投影狀態列方塊和自動停止

Media projection can expose private user information. A new, prominent status bar chip makes users aware of any ongoing screen projection. Users can tap the chip to stop screen casting, sharing, or recording. Also, for a more intuitive user experience, any in‑progress screen projection now automatically stops when the device screen is locked.

Status bar chip for screen sharing, casting, and recording.

大螢幕和板型規格

Android 15 可讓應用程式充分發揮 Android 板型規格的效益,包括大螢幕、翻轉式和折疊式裝置。

改善大螢幕多工處理功能

Android 15 gives users better ways to multitask on large screen devices. For example, users can save their favorite split-screen app combinations for quick access and pin the taskbar on screen to quickly switch between apps. This means that making sure your app is adaptive is more important than ever.

Google I/O has sessions on Building adaptive Android apps and Building UI with the Material 3 adaptive library that can help, and our documentation has more to help you Design for large screens.

支援封面螢幕

您的应用可以声明一项属性,Android 15 会使用该属性将您的 ApplicationActivity 呈现在支持的可翻转设备的小封面屏幕上。这些屏幕太小,无法被视为 Android 应用的兼容目标,但您的应用可以选择支持这些屏幕,从而让您的应用可在更多位置使用。

連線能力

Android 15 會更新平台,讓應用程式能夠使用最新的通訊和無線技術。

衛星支援

Android 15 continues to extend platform support for satellite connectivity and includes some UI elements to ensure a consistent user experience across the satellite connectivity landscape.

Apps can use ServiceState.isUsingNonTerrestrialNetwork() to detect when a device is connected to a satellite, giving them more awareness of why full network services might be unavailable. Additionally, Android 15 provides support for SMS and MMS apps as well as preloaded RCS apps to use satellite connectivity for sending and receiving messages.

A notification appears when the device connects to a satellite.

更順暢的 NFC 體驗

Android 15 is working to make the tap to pay experience more seamless and reliable while continuing to support Android's robust NFC app ecosystem. On supported devices, apps can request the NfcAdapter to enter observe mode, where the device listens but doesn't respond to NFC readers, sending the app's NFC service PollingFrame objects to process. The PollingFrame objects can be used to auth ahead of the first communication to the NFC reader, allowing for a one tap transaction in many cases.

In addition, apps can register a filter on supported devices so they can be notified of polling loop activity, which allows for smooth operation with multiple NFC-aware applications.

錢包角色

Android 15 introduces a Wallet role that allows tighter integration with the user's preferred wallet app. This role replaces the NFC default contactless payment setting. Users can manage the Wallet role holder by navigating to Settings > Apps > Default Apps.

The Wallet role is used when routing NFC taps for AIDs registered in the payment category. Taps always go to the Wallet role holder unless another app that is registered for the same AID is running in the foreground.

This role is also used to determine where the Wallet Quick Access tile should go when activated. When the role is set to "None", the Quick Access tile isn't available and payment category NFC taps are only delivered to the foreground app.

安全性

Android 15 可協助您提升應用程式的安全性、保護應用程式的資料,並讓使用者更清楚瞭解及掌控自己的資料。請參閱 Google I/O 的「在 Android 上保護使用者安全」演講,進一步瞭解我們如何改善使用者安全防護機制,並保護應用程式免受新威脅的侵擾。

將 Credential Manager 與自動填入功能整合

Starting with Android 15, developers can link specific views like username or password fields with Credential Manager requests, making it easier to provide a tailored user experience during the sign-in process. When the user focuses on one of these views, a corresponding request is sent to Credential Manager. The resulting credentials are aggregated across providers and displayed in autofill fallback UIs, such as inline suggestions or drop-down suggestions. The Jetpack androidx.credentials library is the preferred endpoint for developers to use and will soon be available to further enhance this feature in Android 15 and higher.

整合單鍵註冊和登入功能,並顯示生物辨識提示

Credential Manager将生物识别提示集成到凭据创建过程中 和登录流程,这样提供商就无需管理 生物识别提示。因此,凭据提供程序只需专注于创建和获取流程的结果,并辅以生物识别流程结果。这一简化的流程创建了更高效、更精简的凭据 创建和检索过程。

端對端加密的金鑰管理

我们在 Android 15 中引入了 E2eeContactKeysManager,它提供用于存储加密公钥的操作系统级 API,有助于 Android 应用中的端到端加密 (E2EE)。

E2eeContactKeysManager 旨在与平台通讯录应用集成,使用户能够集中管理和验证其联系人的公钥。

內容 URI 的權限檢查

Android 15 introduces a set of APIs that perform permission checks on content URIs:

無障礙設定

Android 15 新增了可改善使用者無障礙體驗的功能。

改善點字

在 Android 15 中,TalkBack 可以支持通过 USB 和安全蓝牙使用 HID 标准的盲文显示屏。

此标准与鼠标和键盘使用的标准非常相似,有助于 Android 随着时间的推移而支持更广泛的盲文显示屏。

國際化

Android 15 新增了功能和能力,可在使用不同語言的裝置上提供更完善的使用者體驗。

CJK 變數字型

从 Android 15 开始,中文、日语和韩语 (CJK) 语言的字体文件 NotoSansCJK 现已成为可变字体。可变字体为 CJK 语言的广告素材排版开辟了新的可能性。设计师可以探索更广泛的样式,并创建以前难以或无法实现的具有视觉冲击力的布局。

中文、日语和韩语 (CJK) 语言的可变字体在不同字体宽度下的显示效果。

字元間對齊

从 Android 15 开始,可以通过 使用 JUSTIFICATION_MODE_INTER_CHARACTER。“字词间的理由”原为 最初是在 Android 8.0(API 级别 26)中引入的, Justifications 功能为使用 例如中文、日语等。

使用 JUSTIFICATION_MODE_NONE 的日语文本布局。
使用 JUSTIFICATION_MODE_NONE 的英语文本布局。


使用 JUSTIFICATION_MODE_INTER_WORD 的日语文本布局。
使用 JUSTIFICATION_MODE_INTER_WORD 的英语文本布局。


使用 JUSTIFICATION_MODE_INTER_CHARACTER 的日语文本布局。
使用 JUSTIFICATION_MODE_INTER_CHARACTER 的英语文本布局。

自動換行符號設定

Android 已開始在下列國家/地區支援日文和韓文的詞組換行符號: Android 13 (API 級別 33)。不過,雖然使用詞組的分行符號改善了 簡短的文字易讀性,對長行文字的效果不佳。 在 Android 15 中,應用程式只能針對短行套用以詞組為準的換行符號 方法是使用 LINE_BREAK_WORD_STYLE_AUTO 如果有需要 SQL 指令的分析工作負載 則 BigQuery 可能是最佳選擇這個選項可為文字選取最合適的字詞樣式選項。

以短行文字來說,使用以詞組為基準的換行符號,運作方式也相同 如 LINE_BREAK_WORD_STYLE_PHRASE,如 如下圖片:

如果是簡短的文字,LINE_BREAK_WORD_STYLE_AUTO 套用詞組換行,讓文字更清晰易讀。 這與套用 LINE_BREAK_WORD_STYLE_PHRASE

對於較長的文字,LINE_BREAK_WORD_STYLE_AUTO 會使用 no 斷行文字樣式,功能與 LINE_BREAK_WORD_STYLE_NONE,如 如下圖片:

對於長行文字,LINE_BREAK_WORD_STYLE_AUTO 套用不換行的文字樣式,讓文字更清晰易讀。 這與套用 LINE_BREAK_WORD_STYLE_NONE

額外的日文平假字字型

在 Android 15 中,這是日文平假名 (也稱為 Hentaigana) 的字型檔案 系統預設會整合在一起由於平假名字元的形狀獨特,因此可為圖像或設計增添獨特風格,同時也能確保古代日本文件的正確傳遞和理解。

日本印度正教的字元和文字樣式 字型

VideoLAN 锥形版权所有 (c) 1996-2010 VideoLAN。任何人都可以使用或修改此徽标或修改版本来指代 VideoLAN 项目或 VideoLAN 团队开发的任何产品,但不表示该项目的认可。

Vulkan 和 Vulkan 徽标是 Khronos Group Inc.的注册商标。

OpenGL 是注册商标,OpenGL ES 徽标是 Khronos 许可使用的 Hewlett Packard Enterprise 商标。