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 推出了 低光源增強功能,這是可用於 Camera 2 和 夜間模式相機擴充功能的自動曝光模式。低光源增強功能會在低光源環境中調整預覽串流的曝光量。這與夜間模式相機擴充功能建立靜態圖片的方式不同,因為夜間模式會結合一系列相片,建立單一經過強化的圖片。夜間模式雖然非常適合用於拍攝靜態相片,但無法建立連續的畫面串流,而低光增強功能則可以。因此,低光增強功能可啟用相機功能,例如:
- 提供強化圖片預覽功能,方便使用者在低光源環境下拍攝相片
- 在光線不足的環境下掃描 QR code
啟用低光源增強功能後,系統會在光線較暗時自動開啟,並在光線較強時關閉。
應用程式可以在低光源環境下錄製預覽串流,以便儲存經過調亮的影片。
詳情請參閱「低光增強」。
應用程式內攝影機控制項
Android 15 adds an extension for more control over the camera hardware and its algorithms on supported devices:
- Advanced flash strength adjustments enabling precise control of flash
intensity in both
SINGLE
andTORCH
modes while capturing images.
HDR 頭尾空間控制
Android 15 会选择适合底层设备功能和面板位深的 HDR 余量。对于包含大量 SDR 内容的网页(例如显示单个 HDR 缩略图的消息应用),此行为最终可能会对 SDR 内容的感知亮度产生不利影响。在 Android 15 中,您可以使用 setDesiredHdrHeadroom
控制 HDR 余量,以便在 SDR 内容和 HDR 内容之间取得平衡。

音量控制
Android 15 引入了对 CTA-2075 响度标准的支持,可帮助您避免音频响度不一致,并确保用户在切换内容时不必不断调整音量。系统利用输出设备(头戴式耳机和扬声器)的已知特性以及 AAC 音频内容中提供的响度元数据,智能调整音频响度和动态范围压缩级别。
如需启用此功能,您需要确保 AAC 内容中提供响度元数据,并在应用中启用平台功能。为此,您可以通过使用关联的 AudioTrack
中的音频会话 ID 调用其 create 工厂方法来实例化 LoudnessCodecController
对象;这会自动开始应用音频更新。您可以传递 OnLoudnessCodecUpdateListener
来修改或过滤响度参数,然后再将其应用于 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 也将更新,以使用
LoudnessCodecController
API,可实现无缝应用集成。
虛擬 MIDI 2.0 裝置
Android 13 added support for connecting to MIDI 2.0 devices using USB, which communicate using Universal MIDI Packets (UMP). Android 15 extends UMP support to virtual MIDI apps, enabling composition apps to control synthesizer apps as a virtual MIDI 2.0 device just like they would with an USB MIDI 2.0 device.
更有效率的 AV1 軟體解碼
dav1d 是 VideoLAN 推出的熱門 AV1 軟體解碼器,適用於不支援硬體 AV1 解碼功能的 Android 裝置。dav1d 的效能比舊版 AV1 軟體解碼器高出 3 倍,可讓更多使用者 (包括部分低階和中階裝置) 播放 HD AV1 影片。
您的應用程式必須透過名稱 "c2.android.av1-dav1d.decoder"
呼叫 dav1d,才能選擇使用 dav1d。在後續更新中,dav1d 將成為預設的 AV1 軟體解碼器。這項支援功能已標準化,並向後移植至接收 Google Play 系統更新的 Android 11 裝置。
開發人員工作效率和工具
雖然我們大部分的工作都是圍繞著 Android Studio、Jetpack Compose 和 Android Jetpack 程式庫等工具,來提升您的工作效率,但我們也一直在尋找各種方法,讓您能更輕鬆地在平台上實現願景。
OpenJDK 17 更新
Android 15 将继续更新 Android 的核心库,以与最新 OpenJDK LTS 版本中的功能保持一致。
其中包含以下主要功能和改进:
- 改进了 NIO 缓冲区的使用体验
- 数据流
- 其他
math
和strictmath
方法 util
软件包更新,包括顺序的collection
、map
和set
Deflater
中的ByteBuffer
支持- 安全更新,例如
X500PrivateCredential
和安全密钥更新
这些 API 会通过 Google Play 系统更新在搭载 Android 12(API 级别 31)及更高版本的 10 亿多部设备上更新,以便您以最新的编程功能为目标平台。
PDF 改善功能
Android 15 对 PdfRenderer
API 进行了重大改进。应用可以整合呈现等高级功能
受密码保护的文件、注释、表单编辑、
searching,而 selection 则包含副本。支持线性化 PDF 优化,此功能可加快本地 PDF 查看速度并减少资源使用量。Jetpack PDF 库使用这些 API 来简化 PDF 的添加
查看功能。

PdfRenderer
已移至一个可使用 Google
Play 系统更新独立于平台版本,并且我们支持
将这些变更还原到 Android 11(API 级别 30),方法是创建兼容的
Android 15 之前版本的 API Surface,称为
PdfRendererPreV
。
自動切換語言的細微調整
Android 14 在音频中添加了设备端多语言识别功能,并支持在语言之间自动切换,但这可能会导致丢失字词,尤其是当两次语音之间语言切换的间隔时间较短时。Android 15 添加了其他控件,以帮助应用根据其用例调整此切换。EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS
会将自动切换限制在音频会话开始时,而 EXTRA_LANGUAGE_SWITCH_MATCH_SWITCHES
会在发生指定次数的切换后停用语言切换。如果您预计会话期间只会使用一种语言,并且该语言应被自动检测到,这些选项会特别有用。
改善 OpenType Variable Font API
Android 15 提高了 OpenType 可变字体的易用性。现在,您可以
基于可变字体创建 FontFamily
实例,而不指定
使用 buildVariableFamily
API 绘制权重轴。文本渲染程序替换项
wght
轴的值,以与显示的文本匹配。
使用新的 API,这可以简化用于创建 Typeface
的代码
大量:
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();
以前,如需创建相同的 Typeface
,您需要更多代码:
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();
以下示例展示了如何同时使用新旧 API 创建 Typeface
呈现:
在此示例中,使用旧 API 创建的 Typeface
不包含
为 350、450、550 和 650 创建准确的字体粗细
Font
实例,因此渲染程序会回退到最接近的权重。在
在此示例中,系统会渲染 300 而不是 350,渲染 400 而不是 450,
依此类推。相比之下,使用新 API 创建的 Typeface
会动态创建
给定权重的 Font
实例,因此系统会渲染 350 的准确权重,
450、550 和 650。
精細的換行符號控制
從 Android 15 開始,TextView
和基礎的斷行元件可保留文字的指定部分,以便在同一行中顯示,藉此改善可讀性。您可以在字串資源或 createNoBreakSpan
中使用 <nobreak>
標記,充分利用這項換行自訂功能。同樣地,您也可以使用 <nohyphen>
標記或 createNoHyphenationSpan
,避免系統斷字。
舉例來說,下列字串資源未包含換行符號,因此在顯示「Pixel 8 Pro」時,文字會在不適當的位置中斷:
<resources>
<string name="pixel8pro">The power and brains behind Pixel 8 Pro.</string>
</resources>
相反地,這個字串資源包含 <nobreak>
標記,可將「Pixel 8 Pro」這個詞組包起來,並防止換行:
<resources>
<string name="pixel8pro">The power and brains behind <nobreak>Pixel 8 Pro.</nobreak></string>
</resources>
下圖顯示這些字串的算繪方式差異:

<nobreak>
標記包裝「Pixel 8 Pro」詞組的一行文字版面配置。
<nobreak>
標記包裝。應用程式封存
Android 和 Google Play 宣布支持最后的应用归档功能 年,这让用户可以通过移除部分内容来释放空间 通过 Android 应用发布的设备中不常用的应用 前往 Google Play 下载套装。Android 15 在操作系统级别支持应用归档和解压缩,让所有应用商店都能更轻松地实现归档和解压缩。
具有 REQUEST_DELETE_PACKAGES
权限的应用可以调用
PackageInstaller
requestArchive
方法请求归档
已安装的应用软件包,这会移除 APK 和所有缓存的文件,但会保留
用户数据已归档的应用会通过 LauncherApps
API 作为可显示的应用返回;用户会看到一个界面处理,以突出显示这些应用已归档。如果用户点按已归档的应用,负责安装的应用会收到解除归档请求,并且可以通过 ACTION_PACKAGE_ADDED
广播监控恢复过程。
使用開發人員選項在裝置上啟用 16 KB 模式

切換「Boot with 16KB page size」 開發人員選項,以 16 KB 模式啟動裝置。
從 Android 15 QPR1 開始,您可以使用特定裝置上的開發人員選項,以 16 KB 模式啟動裝置,並執行裝置端測試。使用開發人員選項前,請依序前往「設定」->「系統」->「軟體更新」,然後套用任何可用的更新。
這個開發人員選項適用於下列裝置:
Pixel 8 和 8 Pro (搭載 Android 15 QPR1 以上版本)
警告:由於已知的 Android 15 QPR2 Beta 版 3 問題,在安裝 Android 15 QPR2 Beta 版 3 並以 16 KB 模式啟動裝置後,Pixel 8 裝置的觸控螢幕就無法運作。這項問題不會影響 Pixel 8 Pro 裝置。
Pixel 8a (搭載 Android 15 QPR1 以上版本)
警告:由於已知的 Android 15 QPR2 Beta 版 3 問題,在安裝 Android 15 QPR2 Beta 版 3 並以 16 KB 模式啟動裝置後,Pixel 8a 裝置上的觸控螢幕就無法運作。
Pixel 9、Pixel 9 Pro 和 Pixel 9 Pro XL (搭載 Android 15 QPR2 Beta 2 以上版本)
圖形
Android 15 提供最新的圖形改善功能,包括 ANGLE 和 Canvas 圖形系統的新增功能。
改良 Android 的 GPU 存取權
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

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
在以前的 Android 版本中,应用启动一直是个谜。在应用中确定应用是从冷启动、温启动还是热启动状态启动很困难。您还很难了解应用在各种启动阶段(分叉进程、调用 onCreate
、绘制第一个帧等)所花的时间。在 Application
类被实例化时,您无法知道应用是通过广播、content provider、作业、备份、启动完成、闹钟还是 Activity
启动的。
Android 15 上的 ApplicationStartInfo
API 提供了所有这些功能,以及更多功能。您甚至可以选择在流程中添加自己的时间戳,以便在一个位置收集时间数据。除了收集指标之外,您还可以使用 ApplicationStartInfo
直接优化应用启动;例如,您可以消除在应用因广播而启动时在 Application
类中实例化与界面相关的库所带来的高昂开销。
詳細的應用程式大小資訊
从 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()
andbeginTransactionWithListenerReadOnly(SQLiteTransactionListener)
to issue read-onlyDEFERRED
transactions. Such transactions can run concurrently with each other, and if the database is in WAL mode, they can run concurrently withIMMEDIATE
orEXCLUSIVE
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, whilegetTotalChangedRowCount()
returns the count on the current connection.getLastInsertRowId()
returns therowid
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 持續投入 Android 動態效能架構 (ADPF),這組 API 可讓遊戲和需要耗用大量效能執行的應用程式,直接與 Android 裝置的電力和熱溫系統互動。在支援的裝置上,Android 15 新增 ADPF 功能:
- 提供提示工作階段的省電模式,用來指出相關聯的執行緒應以省電為優先,而非效能,非常適合長時間執行的背景工作負載。
- GPU 和 CPU 工作時間長度都能在提示工作階段中回報,讓系統同時調整 CPU 和 GPU 頻率,以最佳方式滿足工作負載需求。
- 熱力上升空間閾值:根據上升空間預測結果,解讀可能的熱力限制狀態。
如要進一步瞭解如何在應用程式和遊戲中使用 ADPF,請參閱說明文件。
隱私權
Android 15 提供多種功能,協助應用程式開發人員保護使用者隱私。
螢幕錄影偵測
Android 15 增加了对应用的支持,以检测 正在录制。每当应用转换时,系统都会调用回调 在屏幕录制内容中处于可见与隐藏状态之间。如果正在记录注册进程的 UID 拥有的 activity,则系统会将应用视为可见。这样一来,如果您的应用执行敏感操作,您就可以告知用户正在录制他们的操作。
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
,其中包含一組 UriRelativeFilter
物件,可形成一組必須滿足的 Intent
比對規則,包括網址查詢參數、網址片段,以及封鎖或排除規則。
您可以在 AndroidManifest
XML 檔案中使用 <uri-relative-filter-group>
標記定義這些規則,並視需要納入 android:allow
標記。這些標記可包含使用現有資料標記屬性的 <data>
標記,以及 android:query
和 android:fragment
屬性。
以下是 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>
私人空間
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:
- Apps with logic for work profiles that assumes that any installed copies of their app that aren't in the main profile are in the work profile.
- Medical apps
- Launcher apps
- App store apps
查詢使用者最近一次選取的「指定相片存取權」
Apps can now highlight only the most-recently-selected photos and videos when
partial access to media permissions is granted. This feature can improve
the user experience for apps that frequently request access to photos and
videos. To use this feature in your app, enable the
QUERY_ARG_LATEST_SELECTION_ONLY
argument when querying MediaStore
through ContentResolver
.
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 Ad Services 擴充功能,其中整合了 Android 版 Privacy Sandbox 的最新版本。這項新增功能是我們開發新技術的一部分,旨在強化使用者隱私,並在行動應用程式中提供有效的個人化廣告體驗。我們的 Privacy Sandbox 頁面提供 Android 版 Privacy Sandbox 開發人員預覽版和 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:
- Completion goals around calories burned, distance, duration, repetition, and steps.
- Performance goals around as many repetitions as possible (AMRAP), cadence, heart rate, power, perceived rate of exertion, and speed.
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 之前,您只能指定 靜態圖片或版面配置資源。這些預覽畫面通常與實際小工具放置在主畫面時的外觀大不相同。此外,您無法使用 Jetpack Glance 建立靜態資源,因此 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)
)
預期的流程如下:
- 小工具提供者隨時都會呼叫
setWidgetPreview
。提供的 預覽內容會連同其他供應商資訊保留在AppWidgetService
中。 setWidgetPreview
會透過AppWidgetHost.onProvidersChanged
回呼通知主機已更新的預覽畫面。做為回應 主機重新載入所有供應商資訊。- 在顯示小工具預覽畫面時,主機會檢查
AppWidgetProviderInfo.generatedPreviewCategories
,以及 類別可供使用,呼叫AppWidgetManager.getWidgetPreview
到 會傳回這個供應商的儲存預覽畫面。
何時呼叫 setWidgetPreview
由於沒有回呼可提供預覽畫面,應用程式可以在執行期間隨時選擇傳送預覽畫面。預覽畫面的更新頻率取決於小工具的用途。
以下清單說明預先發布版用途的兩大類別:
- 供應商在小工具預覽畫面中顯示實際資料,例如個人化資料 或最新資訊這些供應商可在使用者登入或在應用程式中完成初始設定後,設定預覽畫面。之後,他們可以設定定期執行的作業,以所選頻率更新預覽畫面。例如相片、日曆、天氣或新聞
- 在預覽畫面中顯示靜態資訊,或在快速操作小工具中不顯示任何資料的供應商。這些供應商可以在應用程式首次啟動時設定預覽畫面。例如快速開車 動作小工具或 Chrome 捷徑小工具
部分供應商可能會在中心模式挑選器中顯示靜態預覽畫面,但實際上 主畫面上挑選器的資訊。這些供應商應依照這兩種用途設定預覽畫面。
子母畫面
Android 15 introduces changes in Picture-in-Picture (PiP) ensuring an even smoother transition when entering into PiP mode. This will be beneficial for apps having UI elements overlaid on top of their main UI, which goes into PiP.
Developers use the onPictureInPictureModeChanged
callback to define logic
that toggles the visibility of the overlaid UI elements. This callback is
triggered when the PiP enter or exit animation is completed. Beginning in
Android 15, the PictureInPictureUiState
class includes another state.
With this UI state, apps targeting Android 15 (API level 35) will observe the
Activity#onPictureInPictureUiStateChanged
callback being invoked with
isTransitioningToPip()
as soon as the PiP animation starts. There are
many UI elements that are not relevant for the app when it is in PiP mode, for
example views or layout that include information such as suggestions, upcoming
video, ratings, and titles. When the app goes to PiP mode, use the
onPictureInPictureUiStateChanged
callback to hide these UI elements. When the
app goes to full screen mode from the PiP window, use
onPictureInPictureModeChanged
callback to unhide these elements, as shown in
the following examples:
override fun onPictureInPictureUiStateChanged(pipState: PictureInPictureUiState) {
if (pipState.isTransitioningToPip()) {
// Hide UI elements
}
}
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
if (isInPictureInPictureMode) {
// Unhide UI elements
}
}
This quick visibility toggle of irrelevant UI elements (for a PiP window) helps ensure a smoother and flicker-free PiP enter animation.
改善「零打擾」規則
AutomaticZenRule
可讓應用程式自訂注意力
管理 (請勿打擾) 規則,並決定何時啟用或停用
具體做法是指示 Kubernetes 建立並維護
一或多個代表這些 Pod 的物件Android 15 大幅強化上述規則,目標是改善
使用者體驗包含以下強化項目:
- 將類型新增至
AutomaticZenRule
,讓系統套用特殊類型 來處理部分規則 - 將圖示新增至
AutomaticZenRule
,讓模式更容易辨識。 - 將
triggerDescription
字串新增至AutomaticZenRule
,用來描述 規則對使用者的有效條件 - 已新增
ZenDeviceEffects
敬上 到AutomaticZenRule
,允許規則觸發灰階等事件 顯示螢幕、夜間模式,或是調暗桌布
為通知管道設定 VibrationEffect
Android 15 支持为传入的通知设置丰富的振动,方法是
频道使用的是NotificationChannel.setVibrationEffect
,因此
您的用户可以区分不同类型的通知
不需要看他们的设备
媒體投影狀態列方塊和自動停止
媒体投放可能会泄露用户的私密信息。一个醒目的新状态栏条状标签可让用户了解任何正在进行的屏幕投影。用户可以点按该条状标签停止投屏、共享或录制屏幕。此外,为了提供更直观的用户体验,当设备屏幕锁定后,所有正在进行的屏幕投影都会自动停止。

大螢幕和板型規格
Android 15 可讓應用程式充分發揮 Android 板型規格的效益,包括大螢幕、翻轉式和折疊式裝置。
改善大螢幕多工處理
Android 15 可讓使用者在大螢幕裝置上更妥善地進行多工處理。適用對象 舉例來說,使用者可以儲存喜愛的分割畫面應用程式組合,以便快速 ,並將工作列固定在畫面上,即可快速切換應用程式。也就是說 確保應用程式會自動調適,比以往更重要。
Google I/O 大會建構可自動調整的 Android 環境 應用程式以及使用 Material 3 建構使用者介面 自動調整程式庫 這能幫助您,而我們的說明文件也更勝以往,能進一步協助您運用大型語言設計 螢幕。
支援封面螢幕
您的应用可以声明一个属性,Android 15 会使用该属性来允许您的 Application
或 Activity
显示在受支持的可翻转设备的小封面屏幕上。这些屏幕太小,无法被视为适合运行 Android 应用的兼容目标平台,但您的应用可以选择支持它们,从而让您的应用在更多平台上可用。
連線能力
Android 15 會更新平台,讓應用程式能夠使用最新的通訊和無線技術。
衛星支援
Android 15 继续扩大对卫星连接的平台支持,并包含一些界面元素,以确保在整个卫星连接环境中提供一致的用户体验。
应用可以使用 ServiceState.isUsingNonTerrestrialNetwork()
执行以下操作:
检测设备是否连接到卫星,让他们更清楚地了解
可能会导致完全网络服务不可用的原因此外,Android 15 支持短信和彩信应用以及预加载的 RCS 应用,以便使用卫星连接发送和接收消息。

更流暢的 NFC 體驗
Android 15 正在努力讓輕觸付款體驗更流暢可靠,同時繼續支援 Android 強大的 NFC 應用程式生態系統。在支援的裝置上,應用程式可以要求 NfcAdapter
進入觀察模式,在該模式下,裝置會聆聽但不會回應 NFC 讀卡器,並傳送應用程式的 NFC 服務 PollingFrame
物件進行處理。PollingFrame
物件可用於在首次與 NFC 讀取器通訊前進行驗證,在許多情況下可支援單按鈕交易。
此外,應用程式可以在支援的裝置上註冊篩選器,以便在檢查迴圈活動發生時收到通知,進而與多個支援 NFC 的應用程式順利運作。
錢包角色
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 引入了一组用于对内容 URI 执行权限检查的 API:
Context.checkContentUriPermissionFull
:此选项会对内容 URI 执行完整权限检查。Activity
清单属性requireContentUriPermissionFromCaller
:此属性会在 activity 启动时对提供的内容 URI 强制执行指定权限。Activity
调用方的ComponentCaller
类:此类表示启动 activity 的应用。
無障礙設定
Android 15 新增了可改善使用者無障礙體驗的功能。
改善點字
In Android 15, we've made it possible for TalkBack to support Braille displays that are using the HID standard over both USB and secure Bluetooth.
This standard, much like the one used by mice and keyboards, will help Android support a wider range of Braille displays over time.
國際化
Android 15 新增了功能和能力,可在使用不同語言的裝置上提供更完善的使用者體驗。
CJK 變數字型
Starting with Android 15, the font file for Chinese, Japanese, and Korean (CJK) languages, NotoSansCJK, is now a variable font. Variable fonts open up possibilities for creative typography in CJK languages. Designers can explore a broader range of styles and create visually striking layouts that were previously difficult or impossible to achieve.

字元間對齊
从 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
选项,针对短文本行应用基于短语的行分隔符。此选项会为文本选择最佳字词样式选项。
对于短文本行,则使用基于短语的换行符,功能相同
为 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
。額外的日文平假字字型
In Android 15, a font file for old Japanese Hiragana (known as Hentaigana) is bundled by default. The unique shapes of Hentaigana characters can add a distinctive flair to artwork or design while also helping to preserve accurate transmission and understanding of ancient Japanese documents.

VideoLAN 圆锥图标 版权所有 (c) 1996-2010 VideoLAN。任何人都可以使用此徽标或修改版徽标来提及 VideoLAN 项目或 VideoLAN 团队开发的任何产品,但这并不表示该项目对其表示认可。
Vulkan 和 Vulkan 徽标是 Khronos Group Inc.的注册商标。
OpenGL 是注册商标,OpenGL ES 徽标是 Hewlett Packard Enterprise 的商标,已获得 Khronos 的许可。