Android 15 平台包含可能對應用程式造成影響的行為變更。無論 targetSdkVersion
為何,當應用程式在 Android 15 上執行時,下列行為變更將會套用至所有應用程式。您應測試應用程式,並視需要修改,以便在適當情況下支援新版本功能。
另請務必查看僅對指定 Android 15 為目標版本的應用程式造成影響的行為變更。
核心功能
Android 15 修改或擴充了 Android 系統的各種核心功能。
套件停止狀態的變更
The intention of the package FLAG_STOPPED
state (which users
can engage in AOSP builds by long-pressing an app icon and selecting "Force
Stop") has always been to keep apps in this state until the user explicitly
removes the app from this state by directly launching the app or indirectly
interacting with the app (through the sharesheet or a widget, selecting the app
as live wallpaper, etc.). In Android 15, we've updated the behavior of the
system to be aligned with this intended behavior. Apps should only be removed
from the stopped state through direct or indirect user action.
To support the intended behavior, in addition to the existing restrictions, the
system also cancels all pending intents when the app enters the
stopped state on a device running Android 15. When the user's actions remove the
app from the stopped state, the ACTION_BOOT_COMPLETED
broadcast is delivered to the app providing an opportunity to re-register any
pending intents.
You can call the new
ApplicationStartInfo.wasForceStopped()
method to confirm whether the app was put into the stopped state.
支援 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 環境中測試應用程式。
优势和性能提升
以 16 KB 頁面大小設定的裝置平均會耗用較多記憶體,但系統和應用程式也能獲得各種效能改善:
- 系統面臨記憶體壓力時,應用程式啟動時間越短:平均低 3.16%,部分受測的應用程式還大幅改善 (最多提升 30%)
- 應用程式啟動期間的耗電量降幅:平均減少 4.56%
- 相機啟動速度更快:熱啟動速度平均快了 4.48%,冷啟動速度平均快了 6.60%
- 縮短系統啟動時間:縮短 8% (平均約 950 毫秒)
這些改善項目是根據初步測試結果而來,實際裝置上的結果可能會有所不同。我們會在持續測試的過程中,針對應用程式可能獲得的效益提供額外分析。
检查您的应用是否受到影响
如果應用程式使用任何原生程式碼,請重新建構應用程式,支援 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 為基礎的表情符號字型
我们移除了基于 PNG 的旧版表情符号字体文件 (NotoColorEmojiLegacy.ttf
),只保留了基于矢量的文件。从 Android 13(API 级别 33)开始,系统表情符号渲染程序使用的表情符号字体文件已从基于 PNG 的文件更改为基于矢量的文件。出于兼容性原因,系统在 Android 13 和 14 中保留了旧版字体文件,以便具有自己的字体渲染程序的应用在能够升级之前继续使用旧版字体文件。
如需检查您的应用是否受到影响,请在应用的代码中搜索对 NotoColorEmojiLegacy.ttf
文件的引用。
您可以通过多种方式自适应应用:
- 使用平台 API 进行文本渲染。您可以将文本渲染到基于位图的
Canvas
,并在必要时使用该Canvas
获取原始图片。 - 为您的应用添加 COLRv1 字体支持。FreeType 开源库在 2.13.0 版及更高版本中支持 COLRv1。
- 作为最后的手段,您可以将旧版表情符号字体文件 (
NotoColorEmoji.ttf
) 捆绑到 APK 中,但在这种情况下,您的应用将缺少最新的表情符号更新。如需了解详情,请参阅 Noto Emoji GitHub 项目页面。
目標 SDK 最低版本從 23 提高至 24
Android 15 builds on the
the changes that were made in Android 14 and extends this
security further. In Android 15, apps with a
targetSdkVersion
lower than 24 can't be installed.
Requiring apps to meet modern API levels helps to ensure better security and
privacy.
Malware often targets lower API levels in order to bypass security and privacy
protections that have been introduced in higher Android versions. For example,
some malware apps use a targetSdkVersion
of 22 to avoid being subjected to the
runtime permission model introduced in 2015 by Android 6.0 Marshmallow (API
level 23). This Android 15 change makes it harder for malware to avoid security
and privacy improvements. Attempting to install an app targeting a lower API
level results in an installation failure, with a message like the following one
appearing in Logcat:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 7
On devices upgrading to Android 15, any apps with a targetSdkVersion
lower
than 24 remain installed.
If you need to test an app targeting an older API level, use the following ADB command:
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 對所有應用程式的相機和媒體行為進行下列變更。
達到資源限制時,直接和卸載音訊播放會使先前開啟的直接或卸載音軌失效
Before Android 15, if an app requested direct or offload audio playback while
another app was playing audio and the resource limits were reached, the app
would fail to open a new AudioTrack
.
Beginning with Android 15, when an app requests direct or offload
playback and the resource
limits are reached, the system invalidates any currently open
AudioTrack
objects which prevent fulfilling the new track request.
(Direct and offload audio tracks are typically opened for playback of compressed audio formats. Common use-cases for playing direct audio include streaming encoded audio over HDMI to a TV. Offload tracks are typically used to play compressed audio on a mobile device with hardware DSP acceleration.)
使用者體驗和系統 UI
Android 15 包含一些變更,旨在打造更一致、直覺的使用者體驗。
為已選擇加入的應用程式啟用預測返回動畫
从 Android 15 开始,预测性返回动画的开发者选项已被移除。现在,如果应用已完全或在 activity 级别选择启用预测性返回手势,则系统会为其显示“返回主屏幕”“跨任务”和“跨 activity”等系统动画。如果您的应用受到了影响,请执行以下操作:
- 确保您的应用已正确迁移,以使用预测性返回手势。
- 确保 fragment 转场效果可与预测性返回导航搭配使用。
- 请弃用动画和框架过渡,改用动画和 androidx 过渡。
- 从
FragmentManager
不认识的返回堆栈迁移。请改用由FragmentManager
或 Navigation 组件管理的返回堆栈。
使用者強制停止應用程式時,小工具會停用
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.
背景網路存取權限制
在 Android 15 中,如果应用在有效的进程生命周期之外启动网络请求,则会收到异常。通常是 UnknownHostException
或其他与套接字相关的 IOException
。在有效生命周期之外发生的网络请求通常是因为应用在不再活跃后,不知不觉地继续发出网络请求。
为缓解此异常,请使用生命周期感知型组件,确保您的网络请求具有生命周期感知功能,并在离开有效的进程生命周期时取消。如果您非常重视即使用户离开应用也要发出网络请求,请考虑使用 WorkManager 调度网络请求,或使用前台服务继续执行对用户可见的任务。
淘汰項目
每個版本發布時,特定 Android API 可能會過時,或需要重構,才能提供更優質的開發人員體驗或支援新的平台功能。在這種情況下,我們會正式淘汰過時的 API,並引導開發人員改用其他 API。
淘汰表示我們已停止提供 API 的官方支援,但開發人員仍可繼續使用。如要進一步瞭解 Android 這個版本的重要淘汰項目,請參閱淘汰項目頁面。