การเปลี่ยนแปลงลักษณะการทํางาน: แอปทั้งหมด

แพลตฟอร์ม Android 15 มีการเปลี่ยนแปลงลักษณะการทำงานที่อาจส่งผลต่อแอปของคุณ การเปลี่ยนแปลงลักษณะการทำงานต่อไปนี้จะมีผลกับแอปทั้งหมดเมื่อแอปทำงานบน Android 15 ไม่ว่าtargetSdkVersion จะเป็นเวอร์ชันใดก็ตาม คุณควรทดสอบแอป แล้วแก้ไข ตามความจำเป็นเพื่อรองรับฟีเจอร์เหล่านี้อย่างเหมาะสม (หากมี)

อย่าลืมตรวจสอบรายการการเปลี่ยนแปลงลักษณะการทำงานที่มีผลกับแอปที่กำหนดเป้าหมายเป็น 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 设备)。如果您的应用直接或通过 SDK 间接使用任何 NDK 库,则需要重新构建应用,才能在这些 16 KB 设备上运行。

随着设备制造商不断制造出具有更大物理内存 (RAM) 的设备,许多此类设备将采用 16 KB(最终甚至更大)的页面大小来优化设备性能。添加对 16 KB 页面大小设备的支持,可让您的应用在这些设备上运行,并帮助您的应用受益于相关的性能改进。如果不重新编译,应用将无法在未来 Android 版本的 16 KB 设备上运行。

为帮助您为应用添加支持,我们提供了相关指南,介绍了如何检查应用是否受到影响、如何重新构建应用(如果适用),以及如何使用模拟器(包括 Android 模拟器的 Android 15 系统映像)在 16 KB 环境中测试应用

优势和性能提升

อุปกรณ์ที่กำหนดค่าหน้าเว็บขนาด 16 KB จะใช้หน่วยความจำโดยเฉลี่ยมากกว่าเล็กน้อย แต่ปรับปรุงประสิทธิภาพการทำงานได้หลากหลายสำหรับทั้งระบบและแอป ดังนี้

  • เวลาเปิดแอปลดลงขณะที่ระบบมีภาระเกี่ยวกับหน่วยความจำ: ลดลงโดยเฉลี่ย 3.16% โดยการปรับปรุงที่เห็นได้ชัดมากขึ้น (สูงสุด 30%) สำหรับบางแอปที่เราทดสอบ
  • การลดพลังงานในระหว่างการเปิดแอป: ลดลง 4.56% โดยเฉลี่ย
  • การเปิดตัวกล้องเร็วขึ้น: Hot Start เร็วขึ้น 4.48% โดยเฉลี่ย และ Cold Start เร็วขึ้น 6.60% โดยเฉลี่ย
  • ปรับปรุงเวลาในการบูตระบบ: เร็วขึ้น 8% (ประมาณ 950 มิลลิวินาที) โดยเฉลี่ย

การปรับปรุงเหล่านี้อิงตามการทดสอบขั้นต้นของเรา และผลลัพธ์ในอุปกรณ์จริงอาจแตกต่างกัน เราจะให้การวิเคราะห์เพิ่มเติมเกี่ยวกับโอกาสในการได้ผู้ใช้ใหม่สำหรับแอปขณะที่เราทำการทดสอบต่อไป

检查您的应用是否受到影响

如果您的应用使用了任何原生代码,则应重新构建应用,使其支持 16 KB 设备。如果您不确定自己的应用是否使用了原生代码,可以使用 APK 分析器来确定是否存在任何原生代码,然后检查您找到的任何共享库的 ELF 段对齐情况。Android Studio 还提供了一些功能,可帮助您自动检测对齐问题

如果您的应用仅使用以 Java 或 Kotlin 编程语言编写的代码(包括所有库或 SDK),则该应用已支持 16 KB 设备。不过,我们建议您在 16 KB 环境中测试应用,以验证应用行为是否出现意外的回归。

การเปลี่ยนแปลงที่จำเป็นสำหรับแอปบางแอปเพื่อให้รองรับพื้นที่ส่วนตัว

Private space is a new feature in Android 15 that 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. Because apps in the private space have restricted visibility, some types of apps need to take additional steps to be able to see and interact with apps in a user's private space.

All apps

Because apps in the private space are kept in a separate user profile, similar to work profiles, apps shouldn't assume that any installed copies of their app that aren't in the main profile are in the work profile. If your app has logic related to work profile apps that make this assumption, you'll need to adjust this logic.

Medical apps

When a user locks the private space, all apps in the private space are stopped, and those apps can't perform foreground or background activities, including showing notifications. This behavior might critically impact the use and function of medical apps installed in the private space.

The private space setup experience warns users that the private space is not suitable for apps that need to perform critical foreground or background activities, such as showing notifications from medical apps. However, apps can't determine whether or not they're being used in the private space, so they can't show a warning to the user for this case.

For these reasons, if you develop a medical app, review how this feature might impact your app and take appropriate actions—such as informing your users not to install your app in the private space—to avoid disrupting critical app capabilities.

Launcher apps

If you develop a launcher app, you must do the following before apps in the private space will be visible:

  1. Your app must be assigned as the default launcher app for the device—that is, possessing the ROLE_HOME role.
  2. Your app must declare the ACCESS_HIDDEN_PROFILES normal permission in your app's manifest file.

Launcher apps that declare the ACCESS_HIDDEN_PROFILES permission must handle the following private space use cases:

  1. Your app must have a separate launcher container for apps installed in the private space. Use the getLauncherUserInfo() method to determine which type of user profile is being handled.
  2. The user must be able to hide and show the private space container.
  3. The user must be able to lock and unlock the private space container. Use the requestQuietModeEnabled() method to lock (by passing true) or unlock (by passing false) the private space.
  4. While locked, no apps in the private space container should be visible or discoverable through mechanisms such as search. Your app should register a receiver for the ACTION_PROFILE_AVAILABLE and ACTION_PROFILE_UNAVAILABLE broadcasts and update the UI in your app when the locked or unlocked state of the private space container changes. Both of these broadcasts include EXTRA_USER, which your app can use to refer to the private profile user.

    You can also use the isQuietModeEnabled() method to check whether the private space profile is locked or not.

App store apps

The private space includes an "Install Apps" button that launches an implicit intent to install apps into the user's private space. In order for your app to receive this implicit intent, declare an <intent-filter> in your app's manifest file with a <category> of 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 基于 在 Android 14 中进行的更改,并扩展了 安全性。在 Android 15 中, 无法安装低于 24 的 targetSdkVersion。 要求应用符合现代 API 级别有助于确保更好的安全性和 保护隐私。

恶意软件通常会以较低的 API 级别为目标平台,以绕过安全和隐私 更高的 Android 版本中引入的保护机制。例如,有些恶意软件应用使用 targetSdkVersion 22,以避免受到 Android 6.0 Marshmallow(API 级别 23)在 2015 年引入的运行时权限模型的约束。这项 Android 15 变更使恶意软件更难以规避安全和隐私权方面的改进限制。尝试安装以较低 API 级别为目标平台的应用将导致安装失败,并且 Logcat 中会显示如下所示的消息:

INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 7

在升级到 Android 15 的设备上,targetSdkVersion 级别较低的任何应用 安装在 Google Play 上

如果您需要测试以旧版 API 级别为目标平台的应用,请使用以下 ADB 命令:

adb install --bypass-low-target-sdk-block FILENAME.apk

ความปลอดภัยและความเป็นส่วนตัว

Android 15 เปิดตัวมาตรการที่มีประสิทธิภาพในการต่อสู้กับการประพฤติมิชอบเกี่ยวกับรหัสผ่านแบบใช้ครั้งเดียว (OTP) และเพื่อปกป้องเนื้อหาที่มีความละเอียดอ่อนของผู้ใช้ โดยมุ่งเน้นที่การเพิ่มความแข็งแกร่งให้กับบริการโปรแกรมรับฟังการแจ้งเตือนและการปกป้องการแชร์หน้าจอ การปรับปรุงที่สำคัญ ได้แก่ การปกปิด OTP จากการแจ้งเตือนที่แอปที่ไม่เชื่อถือเข้าถึงได้ การซ่อนการแจ้งเตือนระหว่างการแชร์หน้าจอ และการรักษาความปลอดภัยของกิจกรรมในแอปเมื่อมีการแสดง OTP การเปลี่ยนแปลงเหล่านี้มีเป้าหมายเพื่อรักษาเนื้อหาที่ละเอียดอ่อนของผู้ใช้ให้ปลอดภัยจากบุคคลที่ไม่ได้รับอนุญาต

นักพัฒนาแอปต้องคำนึงถึงสิ่งต่อไปนี้เพื่อให้แอปของตนเข้ากันได้กับการเปลี่ยนแปลงใน Android 15

การปกปิดข้อมูลบางส่วนใน OTP

Android จะหยุดแอปที่ไม่เชื่อถือซึ่งใช้ NotificationListenerService ไม่ให้อ่านเนื้อหาที่ไม่มีการปกปิดจากการแจ้งเตือนที่ตรวจพบ OTP แอปที่เชื่อถือได้ เช่น การเชื่อมโยงกับเครื่องมือจัดการอุปกรณ์เสริมจะได้รับการยกเว้นจากข้อจำกัดเหล่านี้

การป้องกันการแชร์หน้าจอ

  • ระบบจะซ่อนเนื้อหาการแจ้งเตือนระหว่างเซสชันการแชร์หน้าจอเพื่อรักษาความเป็นส่วนตัวของผู้ใช้ หากแอปใช้ setPublicVersion() แอป Android จะแสดงการแจ้งเตือนเวอร์ชันสาธารณะซึ่งทำหน้าที่เป็นการแจ้งเตือนแทนในบริบทที่ไม่ปลอดภัย ไม่เช่นนั้น ระบบจะปกปิดเนื้อหาการแจ้งเตือนโดยไม่มีบริบทเพิ่มเติม
  • ระบบจะซ่อนเนื้อหาที่ละเอียดอ่อน เช่น การป้อนรหัสผ่าน จากผู้ดูจากระยะไกลเพื่อป้องกันการเปิดเผยข้อมูลที่ละเอียดอ่อนของผู้ใช้
  • ระบบจะซ่อนกิจกรรมจากแอปที่โพสต์การแจ้งเตือนระหว่างการแชร์หน้าจอซึ่งตรวจพบ OTP เนื้อหาแอปจะซ่อนจากผู้ดูระยะไกลเมื่อเปิดใช้งาน
  • นอกจากการระบุช่องที่มีความละเอียดอ่อนโดยอัตโนมัติของ Android แล้ว นักพัฒนาแอปยังทำเครื่องหมายบางส่วนของแอปว่าละเอียดอ่อนด้วยตนเองได้โดยใช้ setContentSensitivity ซึ่งจะซ่อนจากผู้ดูระยะไกลระหว่างการแชร์หน้าจอ
  • นักพัฒนาแอปสามารถเลือกเปิด/ปิดตัวเลือกปิดใช้การป้องกันการแชร์หน้าจอในส่วนตัวเลือกสำหรับนักพัฒนาแอปเพื่อยกเว้นจากการป้องกันการแชร์หน้าจอเพื่อวัตถุประสงค์ในการสาธิตหรือทดสอบ โปรแกรมบันทึกหน้าจอของระบบเริ่มต้นจะได้รับการยกเว้นจากการเปลี่ยนแปลงเหล่านี้ เนื่องจากไฟล์บันทึกจะยังคงอยู่ในอุปกรณ์

กล้องและสื่อ

Android 15 จะทำการเปลี่ยนแปลงลักษณะการทำงานของกล้องและสื่อต่อไปนี้สำหรับแอปทั้งหมด

การเล่นเสียงโดยตรงและการเล่นเสียงที่ออฟโหลดจะทำให้แทร็กเสียงที่เปิดโดยตรงหรือออฟโหลดก่อนหน้านี้ไม่ถูกต้องเมื่อถึงขีดจำกัดของทรัพยากร

ก่อนที่จะมี Android 15 หากแอปขอการเล่นเสียงโดยตรงหรือส่งออกเสียงขณะที่แอปอื่นกำลังเล่นเสียงและถึงขีดจำกัดทรัพยากร แอปจะเปิด AudioTrack ใหม่ไม่สำเร็จ

ตั้งแต่ Android 15 เป็นต้นไป เมื่อแอปขอการเล่นโดยตรงหรือการเล่นแบบออฟโหลดและถึงขีดจำกัดทรัพยากร ระบบจะทำให้ออบเจ็กต์ AudioTrack ที่เปิดอยู่ในปัจจุบันเป็นโมฆะ ซึ่งจะป้องกันไม่ให้มีการตอบสนองคำขอแทร็กใหม่

(โดยทั่วไปแล้ว ระบบจะเปิดแทร็กเสียงแบบส่งตรงและแบบโอนออกสำหรับการเล่นรูปแบบเสียงที่บีบอัด กรณีการใช้งานทั่วไปสำหรับการเล่นเสียงโดยตรง ได้แก่ สตรีมมิงเสียงที่เข้ารหัสผ่าน HDMI ไปยังทีวี โดยปกติแล้วระบบจะใช้การโอนแทร็กเพื่อเล่นเสียงที่บีบอัดแล้วในอุปกรณ์เคลื่อนที่ที่มีการเร่งฮาร์ดแวร์ DSP)

ประสบการณ์ของผู้ใช้และ UI ของระบบ

Android 15 มีการเปลี่ยนแปลงบางอย่างที่มีจุดประสงค์เพื่อสร้างประสบการณ์ของผู้ใช้ที่สอดคล้องกันมากขึ้น และใช้งานง่าย

เปิดใช้ภาพเคลื่อนไหวของการย้อนกลับที่คาดการณ์ได้สำหรับแอปที่เลือกใช้

从 Android 15 开始,预测性返回动画的开发者选项已被移除。现在,如果应用已完全或在 activity 级别选择启用预测性返回手势,则系统会为其显示“返回主屏幕”“跨任务”和“跨 activity”等系统动画。如果您的应用受到了影响,请执行以下操作:

  • 确保您的应用已正确迁移,以使用预测性返回手势。
  • 确保 fragment 转场效果可与预测性返回导航搭配使用。
  • 请弃用动画和框架过渡,改用动画和 androidx 过渡。
  • FragmentManager 不认识的返回堆栈迁移。请改用由 FragmentManager 或 Navigation 组件管理的返回堆栈。

วิดเจ็ตจะปิดใช้เมื่อผู้ใช้บังคับให้แอปหยุด

如果用户在搭载 Android 15 的设备上强制停止应用,系统会暂时停用该应用的所有微件。这些 widget 会灰显,用户无法与其互动。这是因为,从 Android 15 开始,当系统强制停止应用时,会取消应用的所有待处理 intent。

系统会在用户下次启动应用时重新启用这些微件。

如需了解详情,请参阅对软件包停止状态的更改

ชิปแถบสถานะการฉายสื่อจะแจ้งเตือนผู้ใช้เกี่ยวกับการแชร์หน้าจอ การแคสต์ และการบันทึก

屏幕投影漏洞会泄露用户的私密数据(例如财务信息),因为用户不知道自己的设备屏幕正在共享。

对于搭载 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 อย่างเป็นทางการแล้ว แต่ API จะยังคงพร้อมให้บริการแก่นักพัฒนาแอปต่อไป ดูข้อมูลเพิ่มเติมเกี่ยวกับการเลิกใช้งานที่สำคัญใน Android รุ่นนี้ได้ที่หน้าการเลิกใช้งาน