ภาพรวมฟีเจอร์และ API

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

ดูรายการ API ที่เพิ่ม แก้ไข และนำออกโดยละเอียดได้ในรายงานความแตกต่างของ API ดูรายละเอียดเกี่ยวกับ API ที่เพิ่มได้ที่ข้อมูลอ้างอิง Android API — สำหรับ Android 14 ให้มองหา API ที่เพิ่มใน API ระดับ 34 หากต้องการดูส่วนต่างๆ ที่การเปลี่ยนแปลงของแพลตฟอร์มอาจส่งผลต่อแอปของคุณ โปรดดูการเปลี่ยนแปลงลักษณะการทำงานของ Android 14 สำหรับแอปที่กำหนดเป้าหมายเป็น Android 14 และสำหรับแอปทั้งหมด

การทำให้เป็นสากล

ค่ากำหนดภาษาที่ใช้ในแอป

Android 14 ขยายฟีเจอร์ภาษาต่อแอปที่เปิดตัวใน Android 13 (API ระดับ 33) ด้วยความสามารถเพิ่มเติมต่อไปนี้

  • สร้าง localeConfig ของแอปโดยอัตโนมัติ: ตั้งแต่ Android Studio Giraffe Canary 7 และ AGP 8.1.0-alpha07 เป็นต้นไป คุณสามารถกําหนดค่าแอปให้รองรับค่ากําหนดภาษาของแต่ละแอปโดยอัตโนมัติ ปลั๊กอิน Android Gradle จะสร้างไฟล์ LocaleConfig และเพิ่มการอ้างอิงไฟล์ดังกล่าวในไฟล์ Manifest สุดท้ายโดยอิงตามทรัพยากรของโปรเจ็กต์ คุณจึงไม่ต้องสร้างหรืออัปเดตไฟล์ด้วยตนเองอีกต่อไป AGP ใช้ทรัพยากรในโฟลเดอร์ res ของโมดูลแอปและทรัพยากร Dependency ของโมดูลไลบรารีเพื่อระบุภาษาที่จะรวมไว้ในไฟล์ LocaleConfig

  • การอัปเดตแบบไดนามิกสำหรับ localeConfig ของแอป: ใช้วิธีใน setOverrideLocaleConfig() และ getOverrideLocaleConfig() ใน LocaleManager เพื่ออัปเดตรายการภาษาที่รองรับของแอปแบบไดนามิกในการตั้งค่าระบบของอุปกรณ์ ใช้ความยืดหยุ่นนี้เพื่อปรับแต่งรายการภาษาที่รองรับตามภูมิภาค ทำการทดสอบ A/B หรือระบุรายการภาษาที่อัปเดตแล้วหากแอปใช้การพุชฝั่งเซิร์ฟเวอร์สำหรับการแปล

  • ระดับการเข้าถึงภาษาของแอปสําหรับตัวแก้ไขวิธีการป้อนข้อมูล (IME): IME สามารถใช้วิธี getApplicationLocales() เพื่อตรวจสอบภาษาของแอปปัจจุบันและจับคู่ภาษา IME กับภาษานั้น

Grammatical Inflection API

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

การเรียกผู้ใช้ด้วยเพศทางไวยากรณ์ที่ไม่ถูกต้อง เช่น การเรียกผู้หญิงด้วยเพศทางไวยากรณ์ของผู้ชาย อาจส่งผลเสียต่อประสิทธิภาพและทัศนคติของผู้ใช้ ในทางตรงกันข้าม UI ที่มีภาษาที่แสดงเพศตามไวยากรณ์ของผู้ใช้อย่างถูกต้องจะช่วยเพิ่มการมีส่วนร่วมของผู้ใช้ และมอบประสบการณ์การใช้งานที่ปรับให้เหมาะกับผู้ใช้แต่ละคนและฟังดูเป็นธรรมชาติมากขึ้น

Android 14 เปิดตัว Grammatical Inflection API เพื่อช่วยคุณสร้าง UI ที่เน้นผู้ใช้สำหรับภาษาที่มีเพศแบบกำหนดเพศทางไวยากรณ์ ซึ่งจะช่วยให้คุณเพิ่มการรองรับเพศทางไวยากรณ์ได้โดยไม่ต้องรีแฟกทอริงแอป

ค่ากำหนดตามพื้นที่

Regional preferences enable users to personalize temperature units, the first day of the week, and numbering systems. A European living in the United States might prefer temperature units to be in Celsius rather than Fahrenheit and for apps to treat Monday as the beginning of the week instead of the US default of Sunday.

New Android Settings menus for these preferences provide users with a discoverable and centralized location to change app preferences. These preferences also persist through backup and restore. Several APIs and intents—such as getTemperatureUnit and getFirstDayOfWeek— grant your app read access to user preferences, so your app can adjust how it displays information. You can also register a BroadcastReceiver on ACTION_LOCALE_CHANGED to handle locale configuration changes when regional preferences change.

To find these settings, open the Settings app and navigate to System > Languages & input > Regional preferences.

Regional preferences screen in Android system settings.
Temperature options for regional preferences in Android system settings.

การช่วยเหลือพิเศษ

การปรับขนาดแบบอักษรที่ไม่ใช่แบบเชิงเส้นเป็น 200%

ตั้งแต่ Android 14 เป็นต้นไป ระบบจะรองรับการปรับขนาดแบบอักษรได้สูงสุด 200% ซึ่งจะช่วยให้ผู้ใช้ที่มีสายตาเลือนรางมีตัวเลือกการช่วยเหลือพิเศษเพิ่มเติมที่สอดคล้องกับหลักเกณฑ์การช่วยเหลือพิเศษสำหรับเนื้อหาบนเว็บ (WCAG)

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

ทดสอบแอปด้วยการปรับขนาดแบบอักษรที่ไม่ใช่แบบเชิงเส้น

เปิดใช้ขนาดแบบอักษรสูงสุดในการตั้งค่าการช่วยเหลือพิเศษของอุปกรณ์เพื่อทดสอบแอป

หากคุณใช้หน่วยพิกเซลที่ปรับขนาด (sp) เพื่อกำหนดขนาดข้อความอยู่แล้ว ให้ใช้หน่วยต่อไปนี้ ตัวเลือกเพิ่มเติมและการปรับปรุงการปรับขนาดจะถูกใช้โดยอัตโนมัติ ข้อความในแอปของคุณ อย่างไรก็ตาม คุณยังควรทำการทดสอบ UI ด้วย เปิดใช้ขนาดแบบอักษร (200%) เพื่อให้มั่นใจว่าแอปใช้ขนาดแบบอักษร อย่างถูกต้องและรองรับแบบอักษรขนาดใหญ่โดยไม่ส่งผลกระทบต่อความสามารถในการใช้งาน

หากต้องการเปิดใช้ขนาดแบบอักษร 200% ให้ทำตามขั้นตอนต่อไปนี้

  1. เปิดแอปการตั้งค่า แล้วไปที่การช่วยเหลือพิเศษ > ขนาดการแสดงผลและข้อความ
  2. สำหรับตัวเลือกขนาดแบบอักษร ให้แตะไอคอนเครื่องหมายบวก (+) จนกว่าจะเปิดใช้การตั้งค่าขนาดแบบอักษรสูงสุด ดังที่แสดงในรูปภาพประกอบส่วนนี้

ใช้หน่วยพิกเซลที่ปรับขนาด (sp) สำหรับขนาดข้อความ

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

อย่าใช้หน่วย sp สำหรับระยะห่างจากขอบหรือกำหนดความสูงของมุมมองโดยสมมติว่ามีการเว้นระยะห่างจากขอบโดยนัย เนื่องจากการปรับขนาดแบบไม่เชิงเส้นของแบบอักษรอาจทำให้มิติข้อมูล sp ไม่ได้สัดส่วนกัน ดังนั้น 4sp + 20sp อาจไม่เท่ากับ 24sp

แปลงหน่วยพิกเซลที่ปรับขนาด (sp)

ใช้ TypedValue.applyDimension() เพื่อแปลงจากหน่วย sp เป็นพิกเซล และใช้ TypedValue.deriveDimension() เพื่อ แปลงพิกเซลเป็น sp วิธีการเหล่านี้ใช้การปรับขนาดที่ไม่ใช่เชิงเส้นที่เหมาะสม ปรับเส้นโค้งโดยอัตโนมัติ

หลีกเลี่ยงการเขียนโค้ดสมการแบบฮาร์ดโค้ดโดยใช้ Configuration.fontScale หรือ DisplayMetrics.scaledDensity เนื่องจากการปรับขนาดแบบอักษร ไม่เป็นเชิงเส้น ฟิลด์ scaledDensity จะไม่แม่นยำอีกต่อไป fontScale ควรใช้ในฟิลด์ เพื่อวัตถุประสงค์ในการให้ข้อมูลเท่านั้น เนื่องจากแบบอักษร ด้วยค่าสเกลาร์ค่าเดียว

ใช้หน่วย sp สำหรับ lineHeight

กำหนด android:lineHeight โดยใช้หน่วย sp เสมอแทน dp เพื่อให้ความสูงของบรรทัดปรับตามข้อความ มิเช่นนั้น หากข้อความ มีค่าเป็น sp แต่ lineHeight ของคุณมีหน่วยเป็น dp หรือ px ทำให้ไม่ปรับขนาดและดูจอแคบ TextView จะแก้ไข lineHeight โดยอัตโนมัติเพื่อให้เป็นไปตาม สัดส่วนจะยังคงเหมือนเดิม แต่เฉพาะเมื่อทั้ง textSize และ lineHeight มีค่าเท่ากัน ที่กำหนดไว้ในหน่วย sp

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

Ultra HDR สำหรับรูปภาพ

An illustration of Standard Dynamic Range (SDR) versus High Dynamic Range (HDR) image quality.

Android 14 adds support for High Dynamic Range (HDR) images that retain more of the information from the sensor when taking a photo, which enables vibrant colors and greater contrast. Android uses the Ultra HDR format, which is fully backward compatible with JPEG images, allowing apps to seamlessly interoperate with HDR images, displaying them in Standard Dynamic Range (SDR) as needed.

Rendering these images in the UI in HDR is done automatically by the framework when your app opts in to using HDR UI for its Activity Window, either through a manifest entry or at runtime by calling Window.setColorMode(). You can also capture compressed Ultra HDR still images on supported devices. With more colors recovered from the sensor, editing in post can be more flexible. The Gainmap associated with Ultra HDR images can be used to render them using OpenGL or Vulkan.

ซูม โฟกัส ดูตัวอย่างหลังถ่าย และอื่นๆ ในส่วนขยายกล้อง

Android 14 upgrades and improves camera extensions, allowing apps to handle longer processing times, which enables improved images using compute-intensive algorithms like low-light photography on supported devices. These features give users an even more robust experience when using camera extension capabilities. Examples of these improvements include:

การซูมในเซ็นเซอร์

เมื่อ REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE ใน CameraCharacteristics มี SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW แอปของคุณจะใช้ความสามารถขั้นสูงของเซ็นเซอร์เพื่อให้สตรีม RAW ที่ครอบตัดมีจำนวนพิกเซลเท่ากับมุมมองแบบเต็มได้โดยใช้ CaptureRequest ที่มีเป้าหมาย RAW ซึ่งตั้งค่า Use Case ของสตรีมเป็น CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW การใช้การควบคุมการลบล้างคําขอช่วยให้กล้องที่อัปเดตแล้วให้ผู้ใช้ควบคุมการซูมได้ก่อนที่ตัวควบคุมกล้องอื่นๆ จะพร้อมใช้งาน

เสียง USB แบบไม่สูญเสียข้อมูล

Android 14 รองรับรูปแบบเสียงแบบไม่สูญเสียคุณภาพเพื่อให้คุณได้รับประสบการณ์ระดับออดิโอไฟล์ผ่านชุดหูฟังแบบใช้สาย USB คุณสามารถค้นหาอุปกรณ์ USB เพื่อดูแอตทริบิวต์ของมิกเซอร์ที่ต้องการ ลงทะเบียนโปรแกรมรับฟังการเปลี่ยนแปลงแอตทริบิวต์ของมิกเซอร์ที่ต้องการ และกำหนดค่าแอตทริบิวต์ของมิกเซอร์โดยใช้คลาส AudioMixerAttributes คลาสนี้แสดงรูปแบบ เช่น มาสก์ช่อง อัตราตัวอย่าง และลักษณะการทำงานของมิกเซอร์เสียง คลาสนี้ช่วยให้ส่งเสียงได้โดยตรงโดยไม่ต้องผสม ปรับระดับเสียง หรือประมวลผลเอฟเฟกต์

ประสิทธิภาพการทำงานและเครื่องมือสำหรับนักพัฒนาซอฟต์แวร์

Credential Manager

Android 14 เพิ่ม Credential Manager เป็น API ของแพลตฟอร์ม โดยรองรับอุปกรณ์ Android 4.4 (API ระดับ 19) เพิ่มเติมผ่านคลัง Jetpack โดยใช้บริการ Google Play Credential Manager มีเป้าหมายเพื่อช่วยให้ผู้ใช้ลงชื่อเข้าใช้ได้ง่ายขึ้นด้วย API ที่ดึงข้อมูลและจัดเก็บข้อมูลเข้าสู่ระบบด้วยผู้ให้บริการข้อมูลเข้าสู่ระบบที่ผู้ใช้กําหนดค่าไว้ Credential Manager รองรับวิธีการลงชื่อเข้าใช้หลายวิธี รวมถึงชื่อผู้ใช้และรหัสผ่าน พาสคีย์ และโซลูชันการลงชื่อเข้าใช้แบบรวมศูนย์ (เช่น ฟีเจอร์ลงชื่อเข้าใช้ด้วย Google) ใน API เดียว

พาสคีย์มีข้อดีหลายประการ เช่น พาสคีย์สร้างขึ้นตามมาตรฐานอุตสาหกรรม ทำงานได้กับระบบปฏิบัติการและระบบนิเวศของเบราว์เซอร์ต่างๆ รวมถึงใช้ได้กับทั้งเว็บไซต์และแอป

ดูข้อมูลเพิ่มเติมได้ที่เอกสารประกอบเกี่ยวกับเครื่องมือจัดการข้อมูลเข้าสู่ระบบและพาสคีย์และบล็อกโพสต์เกี่ยวกับเครื่องมือจัดการข้อมูลเข้าสู่ระบบและพาสคีย์

Health Connect

Health Connect is an on-device repository for user health and fitness data. It allows users to share data between their favorite apps, with a single place to control what data they want to share with these apps.

On devices running Android versions prior to Android 14, Health Connect is available to download as an app on the Google Play store. Starting with Android 14, Health Connect is part of the platform and receives updates through Google Play system updates without requiring a separate download. With this, Health Connect can be updated frequently, and your apps can rely on Health Connect being available on devices running Android 14 or higher. Users can access Health Connect from the Settings in their device, with privacy controls integrated into the system settings.

Users can get started using Health Connect without a separate app download on devices running Android 14 or higher.
Users can control which apps have access to their health and fitness data through system settings.

Health Connect includes several new features in Android 14, such as exercise routes, allowing users to share a route of their workout which can be visualized on a map. A route is defined as a list of locations saved within a window of time, and your app can insert routes into exercise sessions, tying them together. To ensure that users have complete control over this sensitive data, users must allow sharing individual routes with other apps.

For more information, see the Health Connection documentation and the blogpost on What's new in Android Health.

การอัปเดต OpenJDK 17

Android 14 continues the work of refreshing Android's core libraries to align with the features in the latest OpenJDK LTS releases, including both library updates and Java 17 language support for app and platform developers.

The following features and improvements are included:

  • Updated approximately 300 java.base classes to Java 17 support.
  • Text Blocks, which introduce multi-line string literals to the Java programming language.
  • Pattern Matching for instanceof, which allows an object to be treated as having a specific type in an instanceof without any additional variables.
  • Sealed classes, which allow you restrict which classes and interfaces can extend or implement them.

Thanks to Google Play system updates (Project Mainline), over 600 million devices are enabled to receive the latest Android Runtime (ART) updates that include these changes. This is part of our commitment to give apps a more consistent, secure environment across devices, and to deliver new features and capabilities to users independent of platform releases.

Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

การปรับปรุงสำหรับ App Store

Android 14 เปิดตัว PackageInstaller API หลายรายการที่ช่วยปรับปรุงประสบการณ์ของผู้ใช้สำหรับ App Store

ขอการอนุมัติการติดตั้งก่อนดาวน์โหลด

การติดตั้งหรืออัปเดตแอปอาจต้องการอนุมัติของผู้ใช้ เช่น เมื่อผู้ติดตั้งที่ใช้สิทธิ์ REQUEST_INSTALL_PACKAGES พยายามติดตั้งแอปใหม่ ใน Android เวอร์ชันก่อนๆ แอปสโตร์จะขอการอนุมัติจากผู้ใช้ได้หลังจากมีการเขียน APK ลงในเซสชันการติดตั้งและบันทึกเซสชันแล้วเท่านั้น

ตั้งแต่ Android 14 เป็นต้นไป เมธอด requestUserPreapproval() จะอนุญาตให้ผู้ติดตั้งขอการอนุมัติจากผู้ใช้ก่อนยืนยันเซสชันการติดตั้ง การปรับปรุงนี้ช่วยให้ App Store เลื่อนการดาวน์โหลด APK ไว้ได้จนกว่าจะได้รับการอนุมัติการติดตั้งจากผู้ใช้ นอกจากนี้ เมื่อผู้ใช้อนุมัติการติดตั้งแล้ว แอปสโตร์จะดาวน์โหลดและติดตั้งแอปในเบื้องหลังได้โดยไม่รบกวนผู้ใช้

อ้างความรับผิดชอบสำหรับการอัปเดตในอนาคต

วิธีการ setRequestUpdateOwnership() ช่วยให้ผู้ติดตั้งระบุต่อระบบว่าตนตั้งใจที่จะรับผิดชอบต่อการอัปเดตแอปที่ติดตั้งในอนาคต ความสามารถนี้ช่วยให้สามารถบังคับใช้การเป็นเจ้าของการอัปเดตได้ ซึ่งหมายความว่ามีเพียงเจ้าของการอัปเดตเท่านั้นที่ได้รับอนุญาตให้ติดตั้งการอัปเดตอัตโนมัติในแอป การบังคับใช้การเป็นเจ้าของการอัปเดตช่วยให้มั่นใจได้ว่าผู้ใช้จะได้รับอัปเดตจาก App Store ที่คาดไว้เท่านั้น

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

อัปเดตแอปในเวลาที่รบกวนน้อยลง

โดยปกติแล้ว App Store ต้องการหลีกเลี่ยงการอัปเดตแอปที่ผู้ใช้กำลังใช้งานอยู่ เนื่องจากจะส่งผลให้กระบวนการที่ทำงานอยู่ของแอปหยุดลง ซึ่งอาจขัดจังหวะสิ่งที่ผู้ใช้กำลังทำอยู่

ตั้งแต่ Android 14 เป็นต้นไป InstallConstraints API จะเปิดโอกาสให้ผู้ติดตั้งตรวจสอบว่าการอัปเดตแอปเกิดขึ้นในเวลาที่เหมาะสม ตัวอย่างเช่น แอปสโตร์สามารถเรียกใช้เมธอด commitSessionAfterInstallConstraintsAreMet() เพื่อให้แน่ใจว่าการอัปเดตจะดำเนินการต่อเมื่อผู้ใช้ไม่ได้โต้ตอบกับแอปที่เป็นปัญหาแล้ว

ติดตั้งส่วนแยกที่ไม่บังคับได้อย่างราบรื่น

เมื่อใช้ APK แบบแยก คุณจะส่งฟีเจอร์ของแอปเป็นไฟล์ APK แยกต่างหากได้ แทนที่จะส่งเป็น APK แบบรวม APK แบบแยกช่วยให้ App Store เพิ่มประสิทธิภาพการนำส่งคอมโพเนนต์ต่างๆ ของแอปได้ เช่น แอปสโตร์อาจเพิ่มประสิทธิภาพตามพร็อพเพอร์ตี้ของอุปกรณ์เป้าหมาย PackageInstaller API รองรับการแยกตั้งแต่เปิดตัวใน API ระดับ 22

ใน Android 14 วิธีการ setDontKillApp() ช่วยให้ผู้ติดตั้งระบุได้ว่าไม่ควรหยุดกระบวนการที่ทำงานอยู่ของแอปเมื่อติดตั้งแยกใหม่ App Store สามารถใช้ฟีเจอร์นี้เพื่อติดตั้งฟีเจอร์ใหม่ของแอปได้อย่างราบรื่นขณะที่ผู้ใช้กำลังใช้แอปอยู่

App Bundle ข้อมูลเมตา

Starting in Android 14, the Android package installer lets you specify app metadata, such as data safety practices, to include on app store pages such as Google Play.

ตรวจหาเวลาที่ผู้ใช้จับภาพหน้าจอของอุปกรณ์

To create a more standardized experience for detecting screenshots, Android 14 introduces a privacy-preserving screenshot detection API. This API lets apps register callbacks on a per-activity basis. These callbacks are invoked, and the user is notified, when the user takes a screenshot while that activity is visible.

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

การทำงานที่กำหนดเองของชีตการแชร์และการจัดอันดับที่ดียิ่งขึ้น

Android 14 updates the system sharesheet to support custom app actions and more informative preview results for users.

Add custom actions

With Android 14, your app can add custom actions to the system sharesheet it invokes.

Screenshot of custom actions on the sharesheet.

Improve ranking of Direct Share targets

Android 14 uses more signals from apps to determine the ranking of the direct share targets to provide more helpful results for the user. To provide the most useful signal for ranking, follow the guidance for improving rankings of your Direct Share targets. Communication apps can also report shortcut usage for outgoing and incoming messages.

Direct Share row in the sharesheet, as shown by 1

รองรับภาพเคลื่อนไหวในตัวและภาพเคลื่อนไหวที่กำหนดเองสำหรับท่าทางสัมผัสย้อนกลับแบบคาดเดา

วิดีโอ: การเคลื่อนไหวย้อนกลับแบบคาดเดา

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

Android 14 มีการปรับปรุงหลายอย่างและคำแนะนำใหม่สำหรับฟีเจอร์การย้อนกลับแบบคาดการณ์ ดังนี้

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

การลบล้างต่อแอปของผู้ผลิตอุปกรณ์ที่มีหน้าจอขนาดใหญ่

การลบล้างค่าแอปต่อแอปช่วยให้ผู้ผลิตอุปกรณ์เปลี่ยนลักษณะการทำงานของแอปในอุปกรณ์ที่มีหน้าจอขนาดใหญ่ได้ ตัวอย่างเช่น การลบล้าง FORCE_RESIZE_APP จะสั่งให้ระบบปรับขนาดแอปให้พอดีกับขนาดการแสดงผล (หลีกเลี่ยงโหมดความเข้ากันได้ของขนาด) แม้ว่าจะมีการตั้งค่า resizeableActivity="false" ในไฟล์ Manifest ของแอปก็ตาม

การลบล้างมีวัตถุประสงค์เพื่อปรับปรุงประสบการณ์ของผู้ใช้บนหน้าจอขนาดใหญ่

พร็อพเพอร์ตี้ไฟล์ Manifest ใหม่ช่วยให้คุณปิดใช้การลบล้างผู้ผลิตอุปกรณ์บางรายสำหรับแอปของคุณได้

การลบล้างต่อแอปสำหรับผู้ใช้หน้าจอขนาดใหญ่

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

Android 14 QPR1 ช่วยให้ผู้ใช้ใช้การลบล้างระดับแอปได้ผ่านเมนูการตั้งค่าใหม่ในอุปกรณ์หน้าจอขนาดใหญ่

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

App screen sharing enables users to share an app window instead of the entire device screen during screen content recording.

With app screen sharing, the status bar, navigation bar, notifications, and other system UI elements are excluded from the shared display. Only the content of the selected app is shared.

App screen sharing improves productivity and privacy by enabling users to run multiple apps but limit content sharing to a single app.

ฟีเจอร์ช่วยตอบที่ทำงานด้วย LLM ใน Gboard บน Pixel 8 Pro

On Pixel 8 Pro devices with the December Feature Drop, developers can try out higher-quality smart replies in Gboard powered by on-device Large Language Models (LLMs) running on Google Tensor.

This feature is available as a limited preview for US English in WhatsApp, Line, and KakaoTalk. It requires using a Pixel 8 Pro device with Gboard as your keyboard.

To try it out, first enable the feature in Settings > Developer Options > AiCore Settings > Enable Aicore Persistent.

Next, open a conversation in a supported app to see LLM-powered Smart Reply in Gboard's suggestion strip in response to incoming messages.

Gboard utilizes on-device LLMs to provide higher-quality smart replies.

กราฟิก

เส้นทางจะค้นหาและประมาณค่าได้

Android's Path API is a powerful and flexible mechanism for creating and rendering vector graphics, with the ability to stroke or fill a path, construct a path from line segments or quadratic or cubic curves, perform boolean operations to get even more complex shapes, or all of these simultaneously. One limitation is the ability to find out what is actually in a Path object; the internals of the object are opaque to callers after creation.

To create a Path, you call methods such as moveTo(), lineTo(), and cubicTo() to add path segments. But there has been no way to ask that path what the segments are, so you must retain that information at creation time.

Starting in Android 14, you can query paths to find out what's inside of them. First, you need to get a PathIterator object using the Path.getPathIterator API:

Kotlin

val path = Path().apply {
    moveTo(1.0f, 1.0f)
    lineTo(2.0f, 2.0f)
    close()
}
val pathIterator = path.pathIterator

Java

Path path = new Path();
path.moveTo(1.0F, 1.0F);
path.lineTo(2.0F, 2.0F);
path.close();
PathIterator pathIterator = path.getPathIterator();

Next, you can call PathIterator to iterate through the segments one by one, retrieving all of the necessary data for each segment. This example uses PathIterator.Segment objects, which packages up the data for you:

Kotlin

for (segment in pathIterator) {
    println("segment: ${segment.verb}, ${segment.points}")
}

Java

while (pathIterator.hasNext()) {
    PathIterator.Segment segment = pathIterator.next();
    Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints());
}

PathIterator also has a non-allocating version of next() where you can pass in a buffer to hold the point data.

One of the important use cases of querying Path data is interpolation. For example, you might want to animate (or morph) between two different paths. To further simplify that use case, Android 14 also includes the interpolate() method on Path. Assuming the two paths have the same internal structure, the interpolate() method creates a new Path with that interpolated result. This example returns a path whose shape is halfway (a linear interpolation of .5) between path and otherPath:

Kotlin

val interpolatedResult = Path()
if (path.isInterpolatable(otherPath)) {
    path.interpolate(otherPath, .5f, interpolatedResult)
}

Java

Path interpolatedResult = new Path();
if (path.isInterpolatable(otherPath)) {
    path.interpolate(otherPath, 0.5F, interpolatedResult);
}

The Jetpack graphics-path library enables similar APIs for earlier versions of Android as well.

Custom meshes with vertex and fragment shaders

Android has long supported drawing triangle meshes with custom shading, but the input mesh format has been limited to a few predefined attribute combinations. Android 14 adds support for custom meshes, which can be defined as triangles or triangle strips, and can, optionally, be indexed. These meshes are specified with custom attributes, vertex strides, varying, and vertex and fragment shaders written in AGSL.

The vertex shader defines the varyings, such as position and color, while the fragment shader can optionally define the color for the pixel, typically by using the varyings created by the vertex shader. If color is provided by the fragment shader, it is then blended with the current Paint color using the blend mode selected when drawing the mesh. Uniforms can be passed into the fragment and vertex shaders for additional flexibility.

เครื่องมือแสดงผลบัฟเฟอร์ฮาร์ดแวร์สำหรับ Canvas

To assist in using Android's Canvas API to draw with hardware acceleration into a HardwareBuffer, Android 14 introduces HardwareBufferRenderer. This API is particularly useful when your use case involves communication with the system compositor through SurfaceControl for low-latency drawing.