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

แพลตฟอร์ม 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

Historically, Android has only supported 4 KB memory page sizes, which has optimized system memory performance for the average amount of total memory that Android devices have typically had. Beginning with Android 15, AOSP supports devices that are configured to use a page size of 16 KB (16 KB devices). If your app uses any NDK libraries, either directly or indirectly through an SDK, then you will need to rebuild your app for it to work on these 16 KB devices.

As device manufacturers continue to build devices with larger amounts of physical memory (RAM), many of these devices will adopt 16 KB (and eventually greater) page sizes to optimize the device's performance. Adding support for 16 KB page size devices enables your app to run on these devices and helps your app benefit from the associated performance improvements. Without recompiling, apps won't work on 16 KB devices in future Android releases.

To help you add support for your app, we've provided guidance on how to check if your app is impacted, how to rebuild your app (if applicable), and how to test your app in a 16 KB environment using emulators (including Android 15 system images for the Android Emulator).

Benefits and performance gains

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

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

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

Check if your app is impacted

หากแอปใช้โค้ดเนทีฟ คุณควรสร้างแอปใหม่ ให้รองรับอุปกรณ์ขนาด 16 KB หากไม่แน่ใจว่าแอปใช้โค้ดเนทีฟหรือไม่ คุณสามารถใช้ APK Analyzer เพื่อระบุว่ามีโค้ดเนทีฟหรือไม่ จากนั้นตรวจสอบการจัดแนวของส่วน 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 ออกแล้ว

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 แอปที่มี ติดตั้ง targetSdkVersion ที่ต่ำกว่า 24 ไม่ได้ การกําหนดให้แอปเป็นไปตามระดับ API สมัยใหม่จะช่วยให้มั่นใจได้ว่าแอปจะมีความปลอดภัยและความเป็นส่วนตัวที่ดียิ่งขึ้น

มัลแวร์มักกำหนดเป้าหมายเป็น API ระดับต่ำกว่าเพื่อหลีกเลี่ยงความปลอดภัยและความเป็นส่วนตัว ที่เกิดขึ้นใน Android เวอร์ชันที่สูงกว่า ตัวอย่างเช่น แอปมัลแวร์บางแอปใช้ targetSdkVersion เป็น 22 เพื่อหลีกเลี่ยง Android 6.0 Marshmallow (API) เปิดตัวโมเดลสิทธิ์รันไทม์ในปี 2015 ระดับ 23) การเปลี่ยนแปลงนี้ใน Android 15 ทำให้มัลแวร์หลบเลี่ยงการปรับปรุงด้านความปลอดภัยและความเป็นส่วนตัวได้ยากขึ้น การพยายามติดตั้งแอปที่กำหนดเป้าหมาย API ที่ต่ำกว่า จะทำให้การติดตั้งล้มเหลว โดยมีข้อความเหมือนกับข้อความต่อไปนี้ ปรากฏใน Logcat:

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

ในอุปกรณ์ที่อัปเกรดเป็น Android 15 แอปที่มี targetSdkVersion ต่ำกว่า 24 จะยังคงติดตั้งอยู่

หากต้องการทดสอบแอปที่กำหนดเป้าหมายเป็น 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 มีการเปลี่ยนแปลงบางอย่างที่มีจุดประสงค์เพื่อสร้างประสบการณ์ของผู้ใช้ที่สอดคล้องกันมากขึ้น และใช้งานง่าย

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

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 by FragmentManager or by the Navigation component instead.

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

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

ระบบจะเปิดใช้วิดเจ็ตเหล่านั้นอีกครั้งเมื่อผู้ใช้เปิดแอปในครั้งถัดไป

ดูข้อมูลเพิ่มเติมได้ที่การเปลี่ยนแปลงสถานะ "หยุดแพ็กเกจ"

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

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

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

ชิปแถบสถานะสำหรับการแชร์หน้าจอ แคสต์ และบันทึก

ตรวจสอบว่าแอปของคุณได้รับผลกระทบหรือไม่

โดยค่าเริ่มต้น แอปจะมีชิปแถบสถานะและจะหยุดการฉายหน้าจอโดยอัตโนมัติเมื่อหน้าจอล็อกเปิดใช้งาน

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

การจำกัดการเข้าถึงเครือข่ายในเบื้องหลัง

ใน Android 15 แอปที่เริ่มคำขอเครือข่ายนอกวงจรของกระบวนการที่ถูกต้องจะได้รับข้อยกเว้น โดยปกติแล้ว จะเป็น UnknownHostException หรือ IOException อื่นๆ ที่เกี่ยวข้องกับซ็อกเก็ต คำขอเครือข่ายที่เกิดขึ้นนอกวงจรที่ถูกต้องมักเกิดจากแอปส่งคำขอเครือข่ายต่อไปโดยไม่รู้ตัว แม้ว่าแอปจะไม่ได้ใช้งานแล้วก็ตาม

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

การเลิกใช้งาน

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

การเลิกใช้งานหมายความว่าเราได้สิ้นสุดการสนับสนุน API อย่างเป็นทางการแล้ว แต่ API จะยังคงพร้อมให้บริการแก่นักพัฒนาแอปต่อไป ดูข้อมูลเพิ่มเติมเกี่ยวกับการเลิกใช้งานที่สำคัญใน Android รุ่นนี้ได้ที่หน้าการเลิกใช้งาน