Android 16 มีการทํางานบางอย่างที่อาจส่งผลต่อแอปของคุณเช่นเดียวกับเวอร์ชันก่อนหน้า การเปลี่ยนแปลงลักษณะการทํางานต่อไปนี้มีผลกับแอปที่กําหนดเป้าหมายเป็น Android 16 ขึ้นไปเท่านั้น หากแอปกำหนดเป้าหมายเป็น Android 16 ขึ้นไป คุณควรแก้ไขแอปให้รองรับลักษณะการทำงานเหล่านี้ (หากมี)
นอกจากนี้ โปรดตรวจสอบรายการการเปลี่ยนแปลงลักษณะการทำงานที่ส่งผลต่อแอปทั้งหมดที่ทำงานบน Android 16 โดยไม่คำนึงถึง targetSdkVersion
ของแอป
ประสบการณ์ของผู้ใช้และ UI ของระบบ
Android 16 มีการเปลี่ยนแปลงต่อไปนี้ซึ่งมีจุดประสงค์เพื่อมอบประสบการณ์การใช้งานที่สม่ำเสมอและใช้งานง่ายยิ่งขึ้นแก่ผู้ใช้
การเลิกใช้งานแบบเต็มหน้าจอจะหยุดให้บริการ
Android 15 enforced edge-to-edge for apps targeting Android 15 (API
level 35), but your app could opt-out by setting
R.attr#windowOptOutEdgeToEdgeEnforcement
to true
. For apps
targeting Android 16,
R.attr#windowOptOutEdgeToEdgeEnforcement
is deprecated and disabled, and your
app can't opt-out of going edge-to-edge.
For testing in Android 16 Beta 2, ensure your app supports edge-to-edge and
remove any use of R.attr#windowOptOutEdgeToEdgeEnforcement
. To support
edge-to-edge, see the Compose and Views guidance. Let
us know about concerns in our issue tracker on the feedback page.
ต้องย้ายข้อมูลหรือเลือกไม่ใช้ฟีเจอร์การย้อนกลับแบบคาดคะเน
For apps targeting Android 16 or higher and running on an
Android 16 or higher device, the predictive back system animations
(back-to-home, cross-task, and cross-activity) are enabled by default.
Additionally, onBackPressed
is not called and
KeyEvent.KEYCODE_BACK
is not dispatched anymore.
If your app intercepts the back event and you haven't migrated to predictive
back yet, update your app to use supported back navigation APIs. or
temporarily opt out by setting the
android:enableOnBackInvokedCallback
attribute to false
in the
<application>
or <activity>
tag of your app's AndroidManifest.xml
file.
เลิกใช้งานและปิดใช้ Elegant Font API
Apps targeting Android 15 (API level 35) have the
elegantTextHeight
TextView
attribute set to true
by
default, replacing the compact font with one that is much more readable. You
could override this by setting the elegantTextHeight
attribute to false
.
Android 16 deprecates the
elegantTextHeight
attribute,
and the attribute will be ignored once your app targets Android 16. The "UI
fonts" controlled by these APIs are being discontinued, so you should adapt any
layouts to ensure consistent and future proof text rendering in Arabic, Lao,
Myanmar, Tamil, Gujarati, Kannada, Malayalam, Odia, Telugu or Thai.

elegantTextHeight
behavior for apps targeting Android
14 (API level 34) and lower, or for apps targeting Android 15 (API level 35)
that overrided the default by setting the elegantTextHeight
attribute to false
.
elegantTextHeight
behavior for apps targeting Android
16, or for apps targeting Android 15 (API level 35) that didn't override the
default by setting the elegantTextHeight
attribute to
false
.ฟังก์ชันหลัก
Android 16 มีการเปลี่ยนแปลงต่อไปนี้ซึ่งแก้ไขหรือขยายความสามารถหลักต่างๆ ของระบบ Android
การเพิ่มประสิทธิภาพการจัดกำหนดเวลางานแบบอัตราคงที่
Prior to targeting Android 16, when scheduleAtFixedRate
missed a task execution due to being outside a valid
process lifecycle, all missed executions immediately
execute when the app returns to a valid lifecycle.
When targeting Android 16, at most one missed execution of
scheduleAtFixedRate
is immediately executed when the app
returns to a valid lifecycle. This behavior change is expected to improve app
performance. Test this behavior in your app to check if your app is impacted.
You can also test by using the app compatibility framework
and enabling the STPE_SKIP_MULTIPLE_MISSED_PERIODIC_TASKS
compat flag.
รูปแบบของอุปกรณ์
Android 16 มีการเปลี่ยนแปลงต่อไปนี้สำหรับแอปเมื่อแสดงบนอุปกรณ์หน้าจอขนาดใหญ่
เลย์เอาต์ที่ปรับเปลี่ยนได้
เนื่องจากตอนนี้แอป Android ทำงานได้ในอุปกรณ์ที่หลากหลาย (เช่น โทรศัพท์ แท็บเล็ต อุปกรณ์พับได้ เดสก์ท็อป รถยนต์ และทีวี) และโหมดหน้าต่างบนหน้าจอขนาดใหญ่ (เช่น หน้าจอแยกและหน้าต่างเดสก์ท็อป) นักพัฒนาแอปจึงควรสร้างแอป Android ที่ปรับให้เข้ากับหน้าจอและขนาดหน้าต่างได้ทุกขนาด ไม่ว่าจะวางแนวอุปกรณ์อย่างไรก็ตาม กระบวนทัศน์ต่างๆ เช่น การจำกัดการวางแนวและความสามารถในการปรับขนาดมีข้อจำกัดมากเกินไปในโลกที่มีอุปกรณ์หลายประเภทในปัจจุบัน
ไม่สนใจข้อจำกัดด้านการวางแนว ความสามารถในการปรับขนาด และอัตราส่วนการแสดงผล
สำหรับแอปที่กำหนดเป้าหมายเป็น Android 16 นั้น Android 16 มีการเปลี่ยนแปลงวิธีจัดการข้อจำกัดด้านการวางแนว ความสามารถในการปรับขนาด และอัตราส่วนภาพ บนจอแสดงผลที่มีความกว้างน้อยที่สุดตั้งแต่ 600dp ขึ้นไป ข้อจํากัดนี้จะไม่มีผลอีกต่อไป นอกจากนี้ แอปยังแสดงเต็มหน้าต่างการแสดงผล โดยไม่คำนึงถึงสัดส่วนการแสดงผลหรือการวางแนวที่ผู้ใช้ต้องการ และจะไม่ใช้การครอบตัดเสา
การเปลี่ยนแปลงนี้จะเปิดตัวลักษณะการทํางานแบบใหม่ของแพลตฟอร์ม Android กำลังเปลี่ยนไปใช้รูปแบบที่คาดหวังให้แอปปรับเปลี่ยนให้เข้ากับการวางแนว ขนาดการแสดงผล และสัดส่วนภาพต่างๆ ข้อจำกัด เช่น การวางแนวแบบคงที่หรือความสามารถในการปรับขนาดที่จำกัด จะขัดขวางการปรับแอปให้เข้ากับอุปกรณ์ ดังนั้นเราขอแนะนำให้ทำให้แอปเป็นแบบปรับขนาดได้เพื่อให้ผู้ใช้ได้รับประสบการณ์การใช้งานที่ดีที่สุด
นอกจากนี้ คุณยังทดสอบลักษณะการทํางานนี้ได้โดยใช้ [app compatibility framework][a16-kilo-14] และเปิดใช้UNIVERSAL_RESIZABLE_BY_DEFAULT
flag compat
การเปลี่ยนแปลงที่ส่งผลกับส่วนอื่นในระบบที่พบได้ทั่วไป
การละเว้นข้อจำกัดด้านการวางแนว การปรับขนาด และอัตราส่วนภาพอาจส่งผลต่อ UI ของแอปในอุปกรณ์บางรุ่น โดยเฉพาะองค์ประกอบที่ออกแบบมาสำหรับเลย์เอาต์ขนาดเล็กซึ่งล็อกไว้ในแนวตั้ง เช่น ปัญหาเกี่ยวกับเลย์เอาต์ที่ยืดออก รวมถึงภาพเคลื่อนไหวและคอมโพเนนต์ที่อยู่นอกหน้าจอ การคาดเดาเกี่ยวกับสัดส่วนการแสดงผลหรือการวางแนวอาจทำให้เกิดปัญหาด้านภาพในแอป ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีหลีกเลี่ยงปัญหาดังกล่าวและปรับปรุงลักษณะการทํางานแบบปรับเปลี่ยนของแอป
การเปิดใช้การเปลี่ยนอุปกรณ์จะส่งผลให้มีการสร้างกิจกรรมใหม่มากขึ้น ซึ่งอาจส่งผลให้สถานะผู้ใช้สูญหายหากไม่เก็บรักษาอย่างเหมาะสม ดูวิธีบันทึกสถานะ UI อย่างถูกต้องในบันทึกสถานะ UI
รายละเอียดการติดตั้งใช้งาน
ระบบจะละเว้นแอตทริบิวต์ไฟล์ Manifest และ API รันไทม์ต่อไปนี้ในอุปกรณ์ที่มีหน้าจอขนาดใหญ่ในโหมดเต็มหน้าจอและโหมดหลายหน้าต่าง
screenOrientation
resizableActivity
minAspectRatio
maxAspectRatio
setRequestedOrientation()
getRequestedOrientation()
ระบบจะละเว้นค่าต่อไปนี้สำหรับ screenOrientation
, setRequestedOrientation()
และ getRequestedOrientation()
portrait
reversePortrait
sensorPortrait
userPortrait
landscape
reverseLandscape
sensorLandscape
userLandscape
android:resizeableActivity="false"
,
android:minAspectRatio
และ android:maxAspectRatio
ไม่มีผลต่อความสามารถในการปรับขนาดของการแสดงผล
สําหรับแอปที่กําหนดเป้าหมายเป็น Android 16 ระบบจะไม่สนใจข้อจํากัดด้านการวางแนวของแอป ความสามารถในการปรับขนาด และอัตราส่วนภาพบนหน้าจอขนาดใหญ่โดยค่าเริ่มต้น แต่แอปทุกแอปที่ยังไม่พร้อมใช้งานอย่างเต็มรูปแบบสามารถลบล้างลักษณะการทํางานนี้ชั่วคราวได้โดยการเลือกไม่ใช้ (ซึ่งจะส่งผลให้แอปมีลักษณะการทํางานแบบเดิมในโหมดความเข้ากันได้)
ข้อยกเว้น
ข้อจำกัดด้านการวางแนว ความสามารถในการปรับขนาด และอัตราส่วนการแสดงผลของ Android 16 จะไม่มีผลในกรณีต่อไปนี้
- เกม (ตาม Flag
android:appCategory
) - ผู้ใช้เลือกใช้ลักษณะการทำงานเริ่มต้นของแอปในการตั้งค่าสัดส่วนภาพของอุปกรณ์อย่างชัดเจน
- หน้าจอที่มีขนาดเล็กกว่า
sw600dp
เลือกไม่ใช้ชั่วคราว
หากต้องการเลือกไม่ใช้กิจกรรมที่เฉพาะเจาะจง ให้ประกาศPROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY
พร็อพเพอร์ตี้ไฟล์ Manifest ดังนี้
<activity ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
...
</activity>
หากส่วนต่างๆ ของแอปยังไม่พร้อมใช้งานสำหรับ Android 16 คุณสามารถเลือกไม่ใช้โดยสมบูรณ์ได้โดยใช้พร็อพเพอร์ตี้เดียวกันที่ระดับแอปพลิเคชัน ดังนี้
<application ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
</application>
สุขภาพและการออกกำลังกาย
Android 16 มีการเปลี่ยนแปลงต่อไปนี้ที่เกี่ยวข้องกับข้อมูลสุขภาพและการออกกำลังกาย
สิทธิ์ด้านสุขภาพและการออกกำลังกาย
对于以 Android 16 或更高版本为目标平台的应用,BODY_SENSORS
权限将过渡到 android.permissions.health
下的精细权限,Health Connect 也使用这些权限。之前需要 BODY_SENSORS
或 BODY_SENSORS_BACKGROUND
的任何 API 现在都需要相应的 android.permissions.health
权限。这会影响以下数据类型、API 和前台服务类型:
- 来自 Wear 健康服务的
HEART_RATE_BPM
- Android Sensor Manager 中的
Sensor.TYPE_HEART_RATE
- Wear
ProtoLayout
中的heartRateAccuracy
和heartRateBpm
FOREGROUND_SERVICE_TYPE_HEALTH
,其中需要使用相应的android.permission.health
权限来替代BODY_SENSORS
如果您的应用使用这些 API,则现在应请求相应的精细权限:
- 如需在使用期间监测心率、血氧饱和度或体表温度:请请求
android.permissions.health
下的精细权限,例如READ_HEART_RATE
,而不是BODY_SENSORS
。 - 对于后台传感器访问权限:请求
READ_HEALTH_DATA_IN_BACKGROUND
,而不是BODY_SENSORS_BACKGROUND
。
这些权限与用于保护对 Health Connect(用于存储健康、健身和身心健康数据的 Android 数据存储区)读取数据的权限相同。
การเชื่อมต่อ
Android 16 มีการเปลี่ยนแปลงต่อไปนี้ในกองซ้อนบลูทูธเพื่อปรับปรุงการเชื่อมต่อกับอุปกรณ์ต่อพ่วง
Intent ใหม่สำหรับจัดการการสูญเสียพันธบัตรและการเปลี่ยนแปลงการเข้ารหัส
As part of the Improved bond loss handling, Android 16 also introduces 2 new intents to provide apps with greater awareness of bond loss and encryption changes.
Apps targeting Android 16 can now:
- Receive an
ACTION_KEY_MISSING
intent when remote bond loss is detected, allowing them to provide more informative user feedback and take appropriate actions. - Receive an
ACTION_ENCRYPTION_CHANGE
intent whenever encryption status of the link changes. This includes encryption status change, encryption algorithm change, and encryption key size change. Apps must consider the bond restored if the link is successfully encrypted upon receivingACTION_ENCRYPTION_CHANGE
intent later.
If your app currently uses custom mechanisms for bond loss handling, migrate to
the new intent ACTION_KEY_MISSING
to detect and manage bond loss
events. We recommend your app guide the user to confirm the remote device is in
range before initiating device forgetting and re-pairing.
Moreover, if a device disconnects after ACTION_KEY_MISSING
intent
is received, your app should be mindful about reconnecting to the device as that
device may no longer be bonded with the system.