Android 15 平台包含可能對應用程式造成影響的行為變更。無論 targetSdkVersion
為何,當應用程式在 Android 15 上執行時,下列行為變更將會套用至所有應用程式。您應測試應用程式,並視需要修改,以便在適當情況下支援新版本功能。
另請務必查看僅對指定 Android 15 為目標版本的應用程式造成影響的行為變更。
核心功能
Android 15 修改或擴充了 Android 系統的各種核心功能。
套件停止狀態的變更
套件 FLAG_STOPPED
狀態的意圖 (使用者可以透過長按應用程式圖示並選取「強制停止」來啟用 AOSP 版本) 一向是讓應用程式維持在這個狀態,直到使用者透過直接啟動應用程式或間接與應用程式互動 (透過分享畫面或小工具,將應用程式選做動態桌布等) 明確將應用程式移除為止。在 Android 15 中,我們已更新系統行為,以符合這項預期行為。應用程式應僅透過直接或間接的使用者操作,從停止狀態移除。
為了支援預期的行為,除了現有的限制之外,當應用程式在執行 Android 15 的裝置上進入已停止狀態時,系統也會取消所有待處理意圖。當使用者的動作將應用程式從已停止狀態移除時,系統會將 ACTION_BOOT_COMPLETED
廣播傳送至應用程式,讓應用程式有機會重新註冊任何待處理的意圖。
您可以呼叫新的 ApplicationStartInfo.wasForceStopped()
方法,確認應用程式是否已進入停止狀態。
支援 16 KB 頁面大小
過去 Android 僅支援 4 KB 的記憶體分頁大小,這已針對 Android 裝置通常擁有的平均總記憶體量,最佳化系統記憶體效能。從 Android 15 開始,AOSP 支援設定為使用 16 KB 頁面大小的裝置 (16 KB 裝置)。如果應用程式使用任何 NDK 程式庫 (直接或透過 SDK 間接使用),您必須重建應用程式,才能在這些 16 KB 裝置上運作。
隨著裝置製造商持續打造實體記憶體 (RAM) 容量更大的裝置,許多裝置將採用 16 KB (最終會更大) 的分頁大小,以最佳化裝置效能。為 16 KB 頁面大小的裝置新增支援功能,可讓應用程式在這些裝置上執行,並享有相關的效能提升優勢。如果沒有重新編譯,應用程式就無法在日後的 Android 版本中,於 16 KB 裝置上運作。
為協助您為應用程式新增支援功能,我們提供了相關指南,說明如何檢查應用程式是否受到影響、如何重建應用程式 (如適用),以及如何使用模擬器 (包括 Android Emulator 的 Android 15 系統映像檔),在 16 KB 環境中測試應用程式。
Benefits and performance gains
配置为使用 16 KB 页面大小的设备平均会使用略多一些的内存,但系统和应用的性能也会得到各种提升:
- 缩短了系统内存压力时的应用启动时间:平均降低了 3.16%;对于我们测试的某些应用而言,改进幅度更大(最高可达 30%)
- 应用启动期间的功耗降低:平均降低了 4.56%
- 相机启动更快:热启动速度平均提高了 4.48%,冷启动速度平均提高了 6.60%
- 缩短了系统启动时间:平均缩短了 8%(约 950 毫秒)
这些改进基于我们的初始测试,实际设备上的结果可能会有所不同。随着测试的继续进行,我们将进一步分析应用的潜在收益。
Check if your app is impacted
如果您的应用使用了任何原生代码,则应重新构建应用,使其支持 16 KB 设备。如果您不确定自己的应用是否使用了原生代码,可以使用 APK 分析器来确定是否存在任何原生代码,然后检查您找到的任何共享库的 ELF 段对齐情况。Android Studio 还提供了一些功能,可帮助您自动检测对齐问题。
如果您的应用仅使用以 Java 或 Kotlin 编程语言编写的代码(包括所有库或 SDK),则该应用已支持 16 KB 设备。不过,我们建议您在 16 KB 环境中测试应用,以验证应用行为是否出现意外的回归。
部分應用程式支援私人空間的必要變更
私密空间是 Android 15 中推出的一项新功能,可让用户在设备上创建一个单独的空间,在额外的身份验证层保护下,防止敏感应用遭到窥探。由于私密空间中的应用具有受限的公开范围,因此某些类型的应用需要执行额外的步骤,才能查看和与用户私密空间中的应用互动。
所有应用
由于私密空间中的应用会保存在单独的用户资料中(类似于工作资料),因此应用不应假定其任何未位于主资料中的已安装副本都位于工作资料中。如果您的应用包含与工作资料应用相关的逻辑,并且做出了上述假设,则需要调整此逻辑。
医疗应用
当用户锁定私密空间时,私密空间中的所有应用都会停止运行,并且这些应用无法执行前台或后台活动,包括显示通知。此行为可能会严重影响安装在私密空间中的医疗应用的使用和功能。
私密空间设置体验会向用户发出警告,告知私密空间不适合需要执行关键前台或后台活动的应用,例如显示医疗应用发送的通知。不过,应用无法确定自己是否在私密空间中使用,因此无法在这种情况下向用户显示警告。
因此,如果您开发的是医疗应用,请检查此功能可能会对您的应用产生哪些影响,并采取适当的措施(例如告知用户不要在私密空间中安装您的应用),以免中断关键的应用功能。
启动器应用
如果您开发的是启动器应用,则必须执行以下操作,才能看到私密空间中的应用:
- 您的应用必须被指定为设备的默认启动器应用,即具有
ROLE_HOME
角色。 - 您的应用必须在应用的清单文件中声明
ACCESS_HIDDEN_PROFILES
普通权限。
声明 ACCESS_HIDDEN_PROFILES
权限的启动器应用必须处理以下私密空间用例:
- 您的应用必须为安装在私密空间中的应用提供单独的启动器容器。使用
getLauncherUserInfo()
方法确定要处理的用户个人资料类型。 - 用户必须能够隐藏和显示私密空间容器。
- 用户必须能够锁定和解锁私密空间容器。使用
requestQuietModeEnabled()
方法锁定(通过传递true
)或解锁(通过传递false
)私密空间。 在锁定状态下,私密空间容器中的任何应用都应不可见,也无法通过搜索等机制被发现。您的应用应为
ACTION_PROFILE_AVAILABLE
和ACTION_PROFILE_UNAVAILABLE
广播注册接收器,并在私密空间容器的锁定或解锁状态发生变化时更新应用中的界面。这两种状态的广播都包含EXTRA_USER
,您的应用可以使用该常量来引用不公开个人资料的用户。您还可以使用
isQuietModeEnabled()
方法检查私密空间个人资料是否已锁定。
应用商店应用
私密空间包含一个“安装应用”按钮,用于启动隐式 intent 以将应用安装到用户的私密空间。为了让应用能够接收此隐式 intent,请在应用的清单文件中声明一个 <intent-filter>
,并将 <category>
设为 CATEGORY_APP_MARKET
。
移除以 PNG 為基礎的表情符號字型
The legacy, PNG-based emoji font file (NotoColorEmojiLegacy.ttf
) has been
removed, leaving just the vector-based file. Beginning with Android 13 (API
level 33), the emoji font file used by the system emoji renderer changed from a
PNG-based file to a vector based file. The system retained
the legacy font file in Android 13 and 14 for compatibility reasons, so that
apps with their own font renderers could continue to use the legacy font file
until they were able to upgrade.
To check if your app is affected, search your app's code for references to the
NotoColorEmojiLegacy.ttf
file.
You can choose to adapt your app in a number of ways:
- Use platform APIs for text rendering. You can render text to a bitmap-backed
Canvas
and use that to get a raw image if necessary. - Add COLRv1 font support to your app. The FreeType open source library supports COLRv1 in version 2.13.0 and higher.
- As a last resort, you can bundle the legacy emoji font file
(
NotoColorEmoji.ttf
) into your APK, although in that case your app will be missing the latest emoji updates. For more information, see the Noto Emoji GitHub project page.
目標 SDK 最低版本從 23 提高至 24
Android 15 採用
Android 14 所做的變更,並將這項做法
在 Android 15 中,
24 以下版本的 targetSdkVersion
無法安裝。
要求應用程式符合現代 API 級別,有助於提供更完善的安全防護和
隱私權。
為了規避 Android 較新版本的安全性和隱私權保護措施,惡意軟體通常會鎖定較低的 API 級別。例如:
部分惡意軟體應用程式會使用 22 的 targetSdkVersion
,以免受到
Android 6.0 Marshmallow (API) 在 2015 年推出的執行階段權限模型
第 23 級)。這項 Android 15 變更會讓惡意軟體更難躲過更嚴謹的安全性和隱私權措施。嘗試安裝以較低 API 為目標的應用程式
level 會導致安裝失敗,並顯示以下訊息:
出現在 Logcat 中:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 7
在升級至 Android 15 的裝置上,targetSdkVersion
較低的所有應用程式
仍未解除安裝。
如要測試以舊版 API 級別為目標的應用程式,請使用下列 ADB 指令:
adb install --bypass-low-target-sdk-block FILENAME.apk
安全性和隱私權
Android 15 introduces robust measures to combat one-time passcode (OTP) fraud and to protect the user's sensitive content, focusing on hardening the Notification Listener Service and screenshare protections. Key enhancements include redacting OTPs from notifications accessible to untrusted apps, hiding notifications during screenshare, and securing app activities when OTPs are posted. These changes aim to keep the user's sensitive content safe from unauthorized actors.
Developers need to be aware of the following to ensure their apps are compatible with the changes in Android 15:
OTP Redaction
Android will stop untrusted apps that implement a
NotificationListenerService
from reading unredacted content
from notifications where an OTP has been detected. Trusted apps such as
companion device manager associations are exempt from these restrictions.
Screenshare Protection
- Notification content is hidden during screen sharing sessions to preserve
the user's privacy. If the app implements
setPublicVersion()
, Android shows the public version of the notification which serves as a replacement notification in insecure contexts. Otherwise, the notification content is redacted without any further context. - Sensitive content like password input is hidden from remote viewers to prevent revealing the user's sensitive information.
- Activities from apps that post notifications during screenshare where an OTP has been detected will be hidden. App content is hidden from the remote viewer when launched.
- Beyond Android's automatic identification of sensitive fields, developers
can manually mark parts of their app as sensitive using
setContentSensitivity
, which is hidden from remote viewers during screenshare. - Developers can choose to toggle the Disable screen share protections option under Developer Options to be exempted from the screenshare protections for demo or testing purposes. The default system screen recorder is exempted from these changes, since the recordings remain on-device.
相機和媒體
Android 15 對所有應用程式的相機和媒體行為進行下列變更。
達到資源限制時,直接和卸載音訊播放會使先前開啟的直接或卸載音軌失效
在 Android 15 之前,如果某个应用在另一个应用播放音频且达到资源限制时请求直接或分流音频播放,该应用将无法打开新的 AudioTrack
。
从 Android 15 开始,当应用请求直接播放或分流播放且达到资源限制时,系统会使任何当前打开的 AudioTrack
对象失效,以防止执行新轨道请求。
(直接音轨和分流音轨通常会打开,以播放压缩音频格式。播放直接音频的常见用例包括通过 HDMI 将编码的音频流式传输到电视。分流轨道通常用于在具有硬件 DSP 加速的移动设备上播放压缩音频。)
使用者體驗和系統 UI
Android 15 包含一些變更,旨在打造更一致、直覺的使用者體驗。
為已選擇加入的應用程式啟用預測返回動畫
Beginning in Android 15, the developer option for predictive back animations has been removed. System animations such as back-to-home, cross-task, and cross-activity now appear for apps that have opted in to the predictive back gesture either entirely or at an activity level. If your app is affected, take the following actions:
- Ensure that your app has been properly migrated to use the predictive back gesture.
- Ensure that your fragment transitions work with predictive back navigation.
- Migrate away from animation and framework transitions and use animator and androidx transitions instead.
- Migrate away from back stacks that
FragmentManager
doesn't know about. Use back stacks managed byFragmentManager
or by the Navigation component instead.
使用者強制停止應用程式時,小工具會停用
If a user force-stops an app on a device running Android 15, the system temporarily disables all the app's widgets. The widgets are grayed out, and the user cannot interact with them. This is because beginning with Android 15, the system cancels all an app's pending intents when the app is force-stopped.
The system re-enables those widgets the next time the user launches the app.
For more information, see Changes to package stopped state.
媒體投影狀態列晶片會提醒使用者分享螢幕畫面、投放及錄製畫面
螢幕投影漏洞會洩漏使用者的私人資料,例如財務資訊,因為使用者不會察覺自己的裝置螢幕正在分享。
如果應用程式在搭載 Android 15 QPR1 以上版本的裝置上執行,狀態列的方塊會以大而醒目的方式,提醒使用者任何進行中的螢幕投影作業。使用者可以輕觸方塊,停止分享、投放或錄製螢幕畫面。此外,裝置螢幕鎖定時,螢幕投放功能也會自動停止。

Check if your app is impacted
By default, your app includes the status bar chip and automatically suspends screen projection when the lock screen activates.
To learn more about how to test your app for these use cases, see Status bar chip and auto stop.
背景網路存取權限制
In Android 15, apps that start a network request outside of a valid process
lifecycle receive an exception. Typically, an
UnknownHostException
or other socket-related
IOException
. Network requests that happen outside of a valid lifecycle are
usually due to apps unknowingly continuing a network request even after the app
is no longer active.
To mitigate this exception, ensure your network requests are lifecycle aware and cancelled upon leaving a valid process lifecycle by using lifecycle aware components. If it is important that the network request should happen even when the user leaves the application, consider scheduling the network request using WorkManager or continue a user visible task using Foreground Service.
淘汰項目
每個版本發布時,特定 Android API 可能會過時,或需要重構,才能提供更優質的開發人員體驗或支援新的平台功能。在這種情況下,我們會正式淘汰過時的 API,並引導開發人員改用其他 API。
淘汰表示我們已停止提供 API 的官方支援,但開發人員仍可繼續使用。如要進一步瞭解 Android 這個版本的重要淘汰項目,請參閱淘汰項目頁面。