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

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

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

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

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

Android 14 expands on the per-app language features that were introduced in Android 13 (API level 33) with these additional capabilities:

  • Automatically generate an app's localeConfig: Starting with Android Studio Giraffe Canary 7 and AGP 8.1.0-alpha07, you can configure your app to support per-app language preferences automatically. Based on your project resources, the Android Gradle plugin generates the LocaleConfig file and adds a reference to it in the final manifest file, so you no longer have to create or update the file manually. AGP uses the resources in the res folders of your app modules and any library module dependencies to determine the locales to include in the LocaleConfig file.

  • Dynamic updates for an app's localeConfig: Use the setOverrideLocaleConfig() and getOverrideLocaleConfig() methods in LocaleManager to dynamically update your app's list of supported languages in the device's system settings. Use this flexibility to customize the list of supported languages per region, run A/B experiments, or provide an updated list of locales if your app utilizes server-side pushes for localization.

  • App language visibility for input method editors (IMEs): IMEs can utilize the getApplicationLocales() method to check the language of the current app and match the IME language to that language.

API การผันคำตามหลักไวยากรณ์

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

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

为帮助您针对区分性别的语言构建以用户为中心的界面,Android 14 引入了 Grammatical Inflection API,让您无需重构应用便能添加对语法性别的支持。

ค่ากำหนดภูมิภาค

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) 单位来定义文本大小,那么这些额外的选项和缩放改进会自动应用于应用中的文本。但是,您仍然应该在启用最大字体大小 (200%) 的情况下执行界面测试,以确保应用正确应用字体大小,并且可以适应更大的字体大小,而不影响易用性。

要启用 200% 字号,请按以下步骤操作:

  1. 打开“设置”应用,然后依次前往无障碍 > 显示大小和文字
  2. 字号选项中,点按加号 (+) 图标,直到启用最大字号设置,如本部分随附的图片所示。

针对文本大小使用放大像素 (sp) 单位

请务必始终以 sp 为单位指定文本大小。当应用使用 sp 单位时,Android 可以应用用户的首选文本大小并相应地缩放。

不要为内边距使用 sp 单位,也不假设隐式内边距定义视图高度:使用非线性字体缩放 sp 尺寸可能不成比例,因此 4sp + 20sp 可能不等于 24sp。

转换放大像素 (sp) 单位

使用 TypedValue.applyDimension() 从 sp 单位转换为像素,并使用 TypedValue.deriveDimension() 将像素转换为 sp。这些方法会自动应用适当的非线性缩放曲线。

避免使用 Configuration.fontScaleDisplayMetrics.scaledDensity 对方程进行硬编码。由于字体缩放是非线性的,因此 scaledDensity 字段不再准确。fontScale 字段应仅用于提供信息,因为字体不再使用单个标量值进行缩放。

对 lineHeight 使用 sp 单位

始终使用 sp 单位(而非 dp)定义 android:lineHeight,以便行高随文本一起缩放。否则,如果您的文本为 sp,而 lineHeight 以 dp 或 px 为单位,则文本无法缩放且看起来狭窄。TextView 会自动更正 lineHeight 以保留您预期的比例,但前提是以 sp 为单位同时定义 textSizelineHeight

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

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

  • การประมาณเวลาในการตอบสนองของการประมวลผลภาพนิ่งแบบไดนามิกจะให้ค่าประมาณเวลาในการตอบสนองของภาพนิ่งที่แม่นยำกว่ามากโดยอิงตามฉากปัจจุบันและสภาพสภาพแวดล้อม โทรไปที่ CameraExtensionSession.getRealtimeStillCaptureLatency() เพื่อรับออบเจ็กต์ StillCaptureLatency ที่มีวิธีการประมาณเวลาในการตอบสนอง 2 วิธี เมธอด getCaptureLatency() จะแสดงผลเวลาในการตอบสนองโดยประมาณระหว่าง onCaptureStarted กับ onCaptureProcessStarted() และเมธอด getProcessingLatency() จะแสดงผลเวลาในการตอบสนองโดยประมาณระหว่าง onCaptureProcessStarted() กับเวลาที่เฟรมที่ประมวลผลแล้วเฟรมสุดท้ายพร้อมใช้งาน
  • รองรับการเรียกกลับความคืบหน้าในการจับภาพเพื่อให้แอปแสดงความคืบหน้าปัจจุบันของการดำเนินการประมวลผลภาพนิ่งที่ทำงานต่อเนื่องเป็นเวลานาน คุณสามารถตรวจสอบว่าฟีเจอร์นี้พร้อมใช้งานใน CameraExtensionCharacteristics.isCaptureProcessProgressAvailable หรือไม่ หากพร้อมใช้งาน คุณก็สามารถใช้การเรียกกลับ onCaptureProcessProgressed() ซึ่งจะส่งความคืบหน้า (จาก 0 ถึง 100) เป็นพารามิเตอร์
  • ข้อมูลเมตาเฉพาะของชิ้นงาน เช่น CaptureRequest.EXTENSION_STRENGTH สำหรับปรับระดับเอฟเฟกต์ของชิ้นงาน เช่น ระดับการเบลอพื้นหลัง EXTENSION_BOKEH

  • ฟีเจอร์ดูภาพหลังถ่ายสําหรับการจับภาพนิ่งในส่วนขยายกล้อง ซึ่งจะแสดงภาพที่ประมวลผลน้อยลงได้เร็วกว่าภาพสุดท้าย หากชิ้นงานมีความล่าช้าในการประมวลผลเพิ่มขึ้น คุณอาจระบุรูปภาพหลังดูเป็นตัวยึดตําแหน่งเพื่อปรับปรุง UX และเปลี่ยนเป็นรูปภาพสุดท้ายในภายหลัง คุณสามารถตรวจสอบว่าฟีเจอร์นี้พร้อมใช้งานใน CameraExtensionCharacteristics.isPostviewAvailable หรือไม่ จากนั้นคุณสามารถส่ง OutputConfiguration ไปยัง ExtensionSessionConfiguration.setPostviewOutputConfiguration ได้

  • การรองรับ SurfaceView ซึ่งช่วยให้เส้นทางการแสดงผลตัวอย่างได้รับการเพิ่มประสิทธิภาพและประหยัดพลังงานมากขึ้น

  • รองรับการแตะเพื่อโฟกัสและซูมระหว่างการใช้ส่วนขยาย

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

เมื่อ 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 gains support for lossless audio formats for audiophile-level experiences over USB wired headsets. You can query a USB device for its preferred mixer attributes, register a listener for changes in preferred mixer attributes, and configure mixer attributes using the AudioMixerAttributes class. This class represents the format, such as channel mask, sample rate, and behavior of the audio mixer. The class allows for audio to be sent directly, without mixing, volume adjustment, or processing effects.

เครื่องมือและประสิทธิภาพการทำงานของนักพัฒนาแอป

เครื่องมือจัดการข้อมูลเข้าสู่ระบบ

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

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

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

Health Connect

Health Connect 是用户健康与健身数据的设备端仓库。借助该功能,用户可以在一个位置控制要与这些应用共享哪些数据,并在自己喜爱的应用之间共享数据。

在搭载 Android 14 之前的 Android 版本的设备上,Health Connect 可作为应用从 Google Play 商店下载。从 Android 14 开始,Health Connect 将成为 Android 平台的一部分,并通过 Google Play 系统更新接收更新,而无需单独下载。这样一来,Health Connect 就可以频繁更新,您的应用可以依赖于搭载 Android 14 或更高版本的设备上提供的 Health Connect。用户可以通过设备的“设置”访问 Health Connect,隐私控制功能集成到系统设置中。

用户无需在搭载 Android 14 或更高版本的设备上单独下载应用,即可开始使用 Health Connect。
用户可以通过系统设置控制哪些应用可以访问其健康与健身数据。

Health Connect 在 Android 14 中包含多项新功能,例如锻炼路线,可让用户分享可在地图上直观呈现的锻炼路线。路线定义为在一定时间范围内保存的位置列表,您的应用可以将路线插入锻炼时段,将它们关联起来。为确保用户能够完全控制此类敏感数据,用户必须允许与其他应用共享单个路线。

如需了解详情,请参阅 Health Connect 文档以及有关 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.

การปรับปรุงสำหรับร้านค้าแอป

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

กลุ่มข้อมูลเมตาของแอป

ตั้งแต่ Android 14 เป็นต้นไป เครื่องมือติดตั้งแพ็กเกจ Android จะช่วยให้คุณระบุข้อมูลเมตาของแอป เช่น แนวทางปฏิบัติด้านความปลอดภัยของข้อมูล เพื่อรวมไว้ในหน้าร้านค้าแอป เช่น 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

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

Video: Predictive back animations

Android 13 introduced the predictive back-to-home animation behind a developer option. When used in a supported app with the developer option enabled, swiping back shows an animation indicating that the back gesture exits the app back to the home screen.

Android 14 includes multiple improvements and new guidance for Predictive Back:

With this Android 14 preview release, all features of Predictive Back remain behind a developer option. See the developer guide to migrate your app to predictive back, as well as the developer guide to creating custom in-app transitions.

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

Per-app overrides enable device manufacturers to change the behavior of apps on large screen devices. For example, the FORCE_RESIZE_APP override instructs the system to resize the app to fit display dimensions (avoiding size compatibility mode) even if resizeableActivity="false" is set in the app manifest.

Overrides are intended to improve the user experience on large screens.

New manifest properties enable you to disable some device manufacturer overrides for your app.

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

按应用替换项会更改应用在大屏设备上的行为。例如,无论应用的配置如何,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.

กราฟิก

เส้นทางสามารถค้นหาและสลับกันได้

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

หากต้องการสร้าง Path ให้ใช้เมธอด เช่น moveTo(), lineTo() และ cubicTo() เพื่อเพิ่มกลุ่มเส้นทาง แต่ไม่มีวิธีใดที่จะถามถึงเส้นทางว่ากลุ่มเป้าหมายคืออะไร คุณจึงต้องเก็บข้อมูลไว้ ณ เวลาที่สร้าง

ตั้งแต่ Android 14 เป็นต้นไป คุณจะค้นหาเส้นทางเพื่อดูสิ่งที่อยู่ข้างในได้ ก่อนอื่น คุณต้องรับออบเจ็กต์ PathIterator โดยใช้ Path.getPathIterator API โดยทำดังนี้

KotlinJava
val path = Path().apply {
    moveTo(1.0f, 1.0f)
    lineTo(2.0f, 2.0f)
    close()
}
val pathIterator = path.pathIterator
Path path = new Path();
path.moveTo(1.0F, 1.0F);
path.lineTo(2.0F, 2.0F);
path.close();
PathIterator pathIterator = path.getPathIterator();

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

KotlinJava
for (segment in pathIterator) {
    println("segment: ${segment.verb}, ${segment.points}")
}
while (pathIterator.hasNext()) {
    PathIterator.Segment segment = pathIterator.next();
    Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints());
}

PathIterator ยังมี next() เวอร์ชันที่ไม่จัดสรร ซึ่งคุณสามารถส่งบัฟเฟอร์เพื่อเก็บข้อมูลจุดได้

กรณีการใช้งานที่สําคัญอย่างหนึ่งของการค้นหาข้อมูล Path คือการประมาณ เช่น คุณอาจต้องการสร้างภาพเคลื่อนไหว (หรือเปลี่ยนรูปแบบ) ระหว่าง 2 เส้นทางที่แตกต่างกัน Android 14 ยังมีเมธอด interpolate() ใน Path ด้วย เพื่อลดความซับซ้อนของกรณีการใช้งานดังกล่าว สมมติว่าทั้ง 2 เส้นทางมีโครงสร้างภายในเหมือนกัน เมธอด interpolate() จะสร้าง Path ใหม่ด้วยผลลัพธ์ที่ประมาณค่านั้น ตัวอย่างนี้แสดงเส้นทางที่มีรูปร่างครึ่งหนึ่ง (การประมาณค่าในช่วงเชิงเส้นเป็น .5) ระหว่าง path ถึง otherPath

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

ไลบรารี graphics-path ของ Jetpack เปิดใช้ API ที่คล้ายกันสำหรับ Android เวอร์ชันก่อนหน้านี้ด้วย

โครงข่ายที่กำหนดเองที่มีจุดยอดมุมและตัวปรับแสงเงา Fragment

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

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

โปรแกรมแสดงผลบัฟเฟอร์ฮาร์ดแวร์สําหรับ Canvas

Android 14 เปิดตัว HardwareBufferRenderer เพื่อช่วยในการใช้ Canvas API ของ Android เพื่อวาดด้วย GPU ลงใน HardwareBuffer API นี้ ซึ่งจะเป็นประโยชน์อย่างยิ่งเมื่อกรณีการใช้งานของคุณเกี่ยวข้องกับการสื่อสารกับระบบ Compositor ผ่าน SurfaceControl สำหรับเวลาในการตอบสนองต่ำ ภาพวาด